Add multi-view mode support to app startup
Introduces a 'multiView' parameter to the app and conditionally runs the app with 'runWidget' or 'runApp' based on the multi-view mode. This enables support for Flet Web Multi-View mode and improves flexibility in app initialization.
This commit is contained in:
parent
9064573dfa
commit
7d76ef2829
|
|
@ -73,7 +73,7 @@ void main(List<String> args) async {
|
||||||
ext.ensureInitialized();
|
ext.ensureInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
runApp(FutureBuilder(
|
var app = FutureBuilder(
|
||||||
future: prepareApp(),
|
future: prepareApp(),
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
|
|
@ -84,7 +84,8 @@ void main(List<String> args) async {
|
||||||
assetsDir: assetsDir,
|
assetsDir: assetsDir,
|
||||||
showAppStartupScreen: showAppStartupScreen,
|
showAppStartupScreen: showAppStartupScreen,
|
||||||
appStartupScreenMessage: appStartupScreenMessage,
|
appStartupScreenMessage: appStartupScreenMessage,
|
||||||
extensions: extensions)
|
extensions: extensions,
|
||||||
|
multiView: isMultiView())
|
||||||
: FutureBuilder(
|
: FutureBuilder(
|
||||||
future: runPythonApp(args),
|
future: runPythonApp(args),
|
||||||
builder:
|
builder:
|
||||||
|
|
@ -103,7 +104,8 @@ void main(List<String> args) async {
|
||||||
assetsDir: assetsDir,
|
assetsDir: assetsDir,
|
||||||
showAppStartupScreen: showAppStartupScreen,
|
showAppStartupScreen: showAppStartupScreen,
|
||||||
appStartupScreenMessage: appStartupScreenMessage,
|
appStartupScreenMessage: appStartupScreenMessage,
|
||||||
extensions: extensions);
|
extensions: extensions,
|
||||||
|
multiView: isMultiView());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (snapshot.hasError) {
|
} else if (snapshot.hasError) {
|
||||||
|
|
@ -116,7 +118,14 @@ void main(List<String> args) async {
|
||||||
// loading
|
// loading
|
||||||
return MaterialApp(home: showAppBootScreen ? const BootScreen() : const BlankScreen());
|
return MaterialApp(home: showAppBootScreen ? const BootScreen() : const BlankScreen());
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
|
if (isMultiView()) {
|
||||||
|
debugPrint("Flet Web Multi-View mode");
|
||||||
|
runWidget(app);
|
||||||
|
} else {
|
||||||
|
runApp(app);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future prepareApp() async {
|
Future prepareApp() async {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue