context) {
return MaterialApp(
home: SplashScreen(),
);
}
}
class SplashScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FlutterSplashScreen.gif(
useImmersiveMode: true,
backgroundColor: Colors.white,
gifPath: 'assets/animation.gif',
gifWidth: 269,
gifHeight: 474,
nextScreen: MainApp(),
duration: const Duration(milliseconds: 3515),
onInit: () async {
debugPrint("onInit");
},
onEnd: () async {
debugPrint("onEnd 1");
},
);
}
}
class MainApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: prepareApp(), // Call your preparation function
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
// Show a loading indicator while waiting for prepareApp()
return Scaffold(
body: Center(child: CircularProgressIndicator()),
);
} else if (snapshot.hasError) {
// Handle error
return MaterialApp(
home: ErrorScreen(
title: "Error starting app",
text: snapshot.error.toString(),
),
);
} else {
// Successful data loading
return kIsWeb
? FletApp(
pageUrl: pageUrl,
assetsDir: assetsDir,
hideLoadingPage: hideLoadingPage,
createControlFactories: createControlFactories,
)
: FutureBuilder(
future: runPythonApp(),
builder: (BuildContext context, AsyncSnapshot<String?> snapshot) {
if (snapshot.hasData || snapshot.hasError) {
// Error or premature finish
return MaterialApp(
home: ErrorScreen(
title: "Error running app",
text: snapshot.data ?? snapshot.error.toString(),
),
);
} else {
// No result or error
return FletApp(
pageUrl: pageUrl,
assetsDir: assetsDir,
hideLoadingPage: hideLoadingPage,
createControlFactories: createControlFactories,
);
}
},
);
}
},
);
}
}
Стикер
its animated splash screen flutter package https://pub.dev/packages/another_flutter_splash_screen
...
Обсуждают сегодня