upgrader icon indicating copy to clipboard operation
upgrader copied to clipboard

Is there a way to use Upgrader with GETX?

Open Matheusbortolo opened this issue 1 year ago • 5 comments

Is there a way to use Upgrader with GETX?

I have an application that uses GETX in it and the initial method of my application is as follows: I haven't found a way to use both.

@override Widget build(BuildContext context) {

return GetMaterialApp(
  title: 'MyTitle',
  initialRoute: '/splashscreen',
  getPages: AppPages.pages,
  debugShowCheckedModeBanner: false,
  localizationsDelegates: [
    FFLocalizationsDelegate(),
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
  ],
  translations: Translations(),
  locale: locale,
  supportedLocales: const [Locale('en', '')],
  theme: ThemeData(brightness: Brightness.dark),
  darkTheme: ThemeData(brightness: Brightness.dark),
  themeMode: _themeMode,
  // routeInformationParser: _router.routeInformationParser,
  // routerDelegate: _router.routerDelegate,
);

}

Matheusbortolo avatar Aug 08 '24 19:08 Matheusbortolo

@Matheusbortolo Yes, you can use it with GetX:

final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

// ...

GetMaterialApp(
  navigatorKey: navigatorKey,
  // ...
  builder: (context, child) => UpgradeAlert(
    navigatorKey: navigatorKey,
    // ...
    child: child,
  ),
);

I'll note that this is not really specific for GetMaterialApp but since you didn't mention any specific issues, I'm hoping this will be useful 🙂

bcheidemann avatar Mar 10 '25 13:03 bcheidemann

Exception caught by widgets library ═══════════════════════════════════ Multiple widgets used the same GlobalKey. ════════════════════════════════════════════════════════════════════════════════

Not working for me, is anything else I need to add in my app to work? I saw this logs I/flutter (22671): upgrader: initializing I/flutter (22671): upgrader: operatingSystem: android, version: QKQ1.190910.002 V11.0.28.0.QDIMIXM I/flutter (22671): upgrader: packageInfo packageName: com.gnomon.x I/flutter (22671): upgrader: packageInfo appName: myX I/flutter (22671): upgrader: packageInfo version: 1.1.0 I/flutter (22671): upgrader: current locale: en_US I/flutter (22671): upgrader: countryCode: US I/flutter (22671): upgrader: languageCode: en I/flutter (22671): upgrader: lookupById url: https://play.google.com/store/apps/details?id=com.gnomon.x&gl=US&hl=en&_cb=xxxxxxxx upgrader: instantiated I/flutter (22671): upgrader: build UpgradeAlert

I/flutter (22671): upgrader: UpgraderPlayStore: version info: appStoreListingURL: https://play.google.com/store/apps/details?id=com.gnomon.x&gl=US&hl=en&_cb=xxxxxxxx, appStoreVersion: 1.2.0, installedVersion: 1.1.0, isCriticalUpdate: null, minAppVersion: null, releaseNotes:

vickyGeo avatar Apr 16 '25 12:04 vickyGeo

@vickyGeo I didn't do anything specific. If you share your code I might be able to help.

bcheidemann avatar Apr 16 '25 16:04 bcheidemann

@bcheidemann navigatorKey used multiple times in your example code above is that intentional?

vickyGeo avatar May 21 '25 13:05 vickyGeo

@bcheidemann navigatorKey used multiple times in your example code above is that intentional?

@vickyGeo yes it is - very much so! :)

EDIT:

Note that I'm passing the global key only to the navigatorKey props.

From your error it looks like you might have used it as a key on either GetMaterialApp or UpgraderAlert. But without seeing your code I can't say for sure.

bcheidemann avatar May 21 '25 16:05 bcheidemann