我正在开发一个由两个迷你应用程序组成的超级应用程序,每个应用程序都作为一个单独的Flutter 项目.这款超级应用程序有按钮,可以使用Navigator.pushReplacement
启动每个迷你应用程序.然而,我面临着一个问题,当从超级应用程序启动时,迷你应用程序中的assets资源 无法正确加载.
当从其专用项目启动迷你应用程序时,所有图像都正确显示.然而,当从超级应用程序运行时,会显示Unable to load asset... Exception. Assets not found
消息.
assets资源 位于mini app的assets
文件夹中,不会在Superapp项目中复制.
这些迷你应用程序包括在超级应用程序的pubspec.yaml
个中,具体如下:
petshop:
path: ../petshop-walking
petshop_dog_walkers_app:
path: ../petshop_dog_walkers_app
-超级应用main.dart
强:
import 'package:petshop/main.dart' as customer_app;
import 'package:petshop_dog_walkers_app/main.dart' as dog_walkers_app;
....
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
await configureDependencies();
// Configuration executed in mini apps' main.dart
await dog_walkers_app.configureApplication();
await customer_app.configureApplication();
runApp(const Application());
}
通过将包含MaterialApp的小工具推送到Navigator
:
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => const customer_app.PetshopApp(),
),
);
以这样一种方式构建应用程序是否可行:每个应用程序都是一个单独的Flutter 项目,并从超级应用程序启动,还是有必要将它们整合到一个单独的Flutter 项目中?