小编Asu*_*ubu的帖子

一个 Flutter 中可以有两个 Material 应用程序吗?

我向我的应用程序添加了两个材质应用程序,因为我的 futurebuilder 需要上下文,而我创建的其他类无法访问我的提供程序。这是一种可以接受的做法吗???

runApp(
        MaterialApp(
            title: 'register app',
            home: FutureBuilder(
              future: Hive.openBox('store'),
              builder: (context, snapshot) {
                if (snapshot.connectionState == ConnectionState.done) {
                  if (snapshot.hasError)
                    return Text(snapshot.error.toString());
                  else
                    return MultiProvider(providers: [
                      ChangeNotifierProvider.value(
                        value: form_entry(),
                      )
                    ], child: MyApp());
                } else
                  return Scaffold(
                      body: Center(
                    child: Text('error error ooops error'),
                  ));
              },
            )),
      );[enter image description here][1]

// my app class has another material app

 class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home: home_screen(), …
Run Code Online (Sandbox Code Playgroud)

flutter

6
推荐指数
1
解决办法
5527
查看次数

标签 统计

flutter ×1