getx
getx copied to clipboard
if you are running your app on a physical device or emulator, you must exchange your [MaterialApp] for a [GetMaterialApp] but GetMaterialApp if exist
ATTENTION: DO NOT USE THIS FIELD TO ASK SUPPORT QUESTIONS. USE THE PLATFORM CHANNELS FOR THIS. THIS SPACE IS DEDICATED ONLY FOR BUGS DESCRIPTION. Fill in the template. Issues that do not respect the model will be closed.
Describe the bug You are trying to use contextless navigation without a GetMaterialApp or Get.key. If you are testing your app, you can use: [Get.testMode = true], or if you are running your app on a physical device or emulator, you must exchange your [MaterialApp] for a [GetMaterialApp].
**Reproduction code Get.toNamed("/configuracion");
example:
Future<void> main() async {
// WidgetsFlutterBinding.ensureInitialized();
await GetStorage.init();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(TendaGo());
}
class TendaGo extends StatelessWidget {
@override
Widget build(BuildContext context) {
Get.put(GlobalController());
return GetMaterialApp(
initialRoute: '/splash',
translations: Messages(),
locale: Get.deviceLocale,
fallbackLocale: Locale('en'),
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('es', 'ES'), // Arabic, no country code
],
theme: ThemeData(
primaryIconTheme: IconThemeData(
color: Colors.white,
)),
debugShowCheckedModeBanner: false,
title: 'Tenda Go',
home: SplashPage(),
initialBinding: SplashBinding(),
getPages: AppPages.pages,
);
}
}
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Flutter Version: Enter the version of the Flutter you are using
Getx Version: ^4.6.1
Describe on which device you found the bug: ex: All
Minimal reproduce code
Provide a minimum reproduction code for the problem

Maybe you are calling the navigator before the GetMaterialApp is attached. Would you be calling Get.toNamed("/configuracion"); in onInit or class constructor?
Maybe you are calling the navigator before the GetMaterialApp is attached. Would you be calling Get.toNamed("/configuracion"); in onInit or class constructor?
Get.toNamed("/configuracion"); is called in onPress in a button but don't work
Maybe you are calling the navigator before the GetMaterialApp is attached. Would you be calling Get.toNamed("/configuracion"); in onInit or class constructor?
I think the problem is probably that you are trying to navigate with contextless. If you are trying to move from the splashscreen controller to the HomePage (for example), you can wrap Get.to() inside a Future, and this will automatically make it time for GetMaterialApp to be loaded. This worked for me.
