I'm a flutter beginner and I've tried to implement a splash screen using launch_background.xml as bellow:
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ceb_launcher" />
</item> -->
</layer-list>
The splash screen is working fine. When I'm at home screen (that can be a login screen or another screen if the login was successful) and I press the back button the app minimizes (enters at detached state) and when I reopen the app, it gets stuck at splash screen. If I close the app and open it again the splash screen appears for some seconds and then I go to home page.
No erros is shown at debug console just this when the back button is pressed:
E/libEGL (28992): call to OpenGL ES API with no current context (logged once per thread)
And this when I return and the app gets stuck at splash screen:
D/EGL_emulation(28992): eglCreateContext: 0xe3b654c0: maj 2 min 0 rcv 2
D/EGL_emulation(28992): eglCreateContext: 0xe3b65520: maj 2 min 0 rcv 2
D/ (28992): HostConnection::get() New Host Connection established 0xdb871800, tid 29168
D/EGL_emulation(28992): eglMakeCurrent: 0xe3b65520: ver 2 0 (tinfo 0xdb816c30)
D/ (28992): HostConnection::get() New Host Connection established 0xdb899640, tid 29167
D/EGL_emulation(28992): eglMakeCurrent: 0xe3b654c0: ver 2 0 (tinfo 0xdb883bb0)
D/EGL_emulation(28992): eglCreateContext: 0xdb885060: maj 2 min 0 rcv 2
D/EGL_emulation(28992): eglMakeCurrent: 0xdb885060: ver 2 0 (tinfo 0xdb883bb0)
D/EGL_emulation(28992): eglMakeCurrent: 0xe3b654c0: ver 2 0 (tinfo 0xdb883bb0)
D/EGL_emulation(28992): eglMakeCurrent: 0xdb885f60: ver 2 0 (tinfo 0xc9596880)
Here is a piece of my code:
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(AppWidget());
}
class AppWidget extends StatelessWidget {
@override
Widget build(BuildContext context){
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
return MultiProvider(
providers: [
ChangeNotifierProvider.value(value: AuthenticationBLOC(),),
ChangeNotifierProvider.value(value: EquipmentBLOC()),
ChangeNotifierProvider.value(value: ScreenDrawerBLOC()),
],
child:Consumer<AuthenticationBLOC>(builder: (ctx, autentication, _) => MaterialApp(
debugShowCheckedModeBanner: false,
theme: themeAllApp(),
home: isAuthenticated(autentication),
onGenerateRoute: routesApp(context)
),
),
);
}
}
Widget isAuthenticated(AuthenticationBLOC autentication){
if(autentication.authenticated != true){
return FutureBuilder(
future: autentication.tryAutoLogIn(),
builder: (context, snapshot) => snapshot.connectionState == ConnectionState.waiting ?
LoadingScreenWidget() : LogInScreenWidget(),
);
}else{
return Consumer<ScreenDrawerBLOC>(
builder: (context, screen, _) => screen.isTypeScreen ? TypeDeviceScreenWidget() :
ContactScreenWidget(),
);
}
}
I've already ran flutter flutter doctor and it's ok everything.
If anyone has an ideia about what's going on I'll appreciate.