-1

enter image description herei added the getx package to my pubspec.yaml file and import the 'get/get.dart' in main.dart but when i want to use getPages, i cant and it gives an error

I don't know what to try because I don't know much about getx package

  • 1
    hey mate. Please refer to https://stackoverflow.com/help/how-to-ask and improve your question. Among other things, please don't post screenshots. Include the full code, hopefully a minimal reproducible example (https://stackoverflow.com/help/minimal-reproducible-example) include the exact error message, and what you've tried so far. Without this, the question will likely get closed. – Madushan Jan 01 '23 at 13:25

1 Answers1

1

You should use GetMaterialApp widget instead of MaterialApp since its the widget from get package

Example:

import 'package:flutter/material.dart';
import 'package:get/get.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'My App',
      theme: ThemeData(
        scaffoldBackgroundColor: const Color(0xff262626),
        brightness: Brightness.dark,
      ),
      initialRoute: '/',
      getPages: [
        GetPage(name: '/', page: () => HomePage()),
      ],
    );
  }
}
Wimukthi
  • 41
  • 1