颤振多提供者消费者

时间:2021-04-23 22:04:30

标签: flutter dart

我在我的应用程序中使用了提供程序,下面的代码正在运行,但看起来不对 :) 寻找一些帮助如何重新格式化代码以仅使用 child 一次..

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (_) => AppProvider(),
        ),
        ChangeNotifierProvider(
          create: (_) => ThemeProvider(true),
        ),
      ],
      child: Consumer<AppProvider>(
        builder: (ctx, providerApp, _) => Container(
          child: Consumer<ThemeProvider>(
            builder: (ctx, providerTheme, _) => MaterialApp(
              debugShowCheckedModeBanner: false,
              theme: providerTheme.getTheme(),
              home: Splash(),
            ),
          ),
        ),
      ),
    );
  }
}

0 个答案:

没有答案