The-ring-io / flutter_phoenix

Easily restart your application from scratch.
MIT License
153 stars 17 forks source link

Doesn't work if I use GetMaterialApp #8

Closed iqfareez closed 4 years ago

iqfareez commented 4 years ago

Previously i use MaterialApp, and it worked just fine, now I'm using GetMaterialApp and it doen't work :")

Simplified code snippet:

void main() async {
  Get.lazyPut<ThemeController>(() => ThemeController());
  runApp(
    RestartWidget(
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  // This widget is the root
  @override
  Widget build(BuildContext context) {
    ThemeController.to.getThemeModeFromPreferences();
    return GetMaterialApp(
      title: 'My Prayer Time',
      theme: ThemeData.light().copyWith(
        primaryColor: Colors.teal,
        bottomAppBarColor: Colors.teal.shade50,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      darkTheme: ThemeData.dark().copyWith(
        primaryColor: Colors.teal,
        bottomAppBarColor: Colors.teal.withOpacity(0.4),
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      themeMode: ThemeController.to.themeMode,
      home: MyHomePage(),
    );
  }
}
iqfareez commented 4 years ago

Console log when I try to call it

D/InputTransport( 5464): Input channel constructed: fd=105
D/ViewRootImpl@efdb571[Toast]( 5464): setView = android.widget.LinearLayout{5b4df56 V.E...... ......I. 0,0-0,0} TM=true MM=false
V/Toast   ( 5464): Text: Moca in android.widget.Toast$TN@c937bd7
D/ViewRootImpl@efdb571[Toast]( 5464): Relayout returned: old=[0,63][1080,1920] new=[279,1704][801,1820] result=0x7 surface={true 3447855104} changed=true
D/mali_winsys( 5464): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000,  [522x116]-format:1
D/OpenGLRenderer( 5464): eglCreateWindowSurface = 0xe3eb98c0, 0xcd821808
D/ViewRootImpl@efdb571[Toast]( 5464): MSG_RESIZED: frame=[279,1704][801,1820] ci=[0,0][0,0] vi=[0,0][0,0] or=1
[GETX] "GetMaterialController" has been initialized
I/flutter ( 5464): mpt snapshot hasData
I/flutter ( 5464): index of SGR01 is at 49
I/flutter ( 5464): detected index is 49
I/flutter ( 5464): snapshot.hasData
W/libEGL  ( 5464): EGLNativeWindowType 0xcd821808 disconnect failed
D/OpenGLRenderer( 5464): eglDestroySurface = 0xe3eb98c0, 0xcd821800
D/ViewRootImpl@efdb571[Toast]( 5464): dispatchDetachedFromWindow
D/InputTransport( 5464): Input channel destroyed: fd=105
edinsonjohender commented 4 years ago

use it in the materialApp Phoenix( child: GetMaterialApp(), ), That's how it worked for me perfectly.

nareshkatta99 commented 4 years ago

https://github.com/jonataslaw/getx/issues/694#issuecomment-706328025 This might be the solution if you are using GetMaterialApp.

iqfareez commented 4 years ago

Thank you. I will try that. Closing this issue....