我可以用 Provider 包装 MaterialApp 小部件吗?

Can I wrap the MaterialApp widget with the Provider?

我是 Flutter 的新手,我正在尝试使用提供程序创建一个应用程序。我用 ChangeNotifierProvider 包装了 MaterialApp 小部件,应用程序可以正常工作,我可以按预期使用提供程序。我需要知道这样做是否可以,我会遇到任何问题吗?

Widget build(BuildContext context) {
    return ChangeNotifierProvider<BaseModel>(
        builder: (context) =>
            BaseModel(loading: false, title: "Title", isLoggedIn: false),
        child: MaterialApp(
            routes: <String, WidgetBuilder>{
                "/home": (BuildContext context) => Home(),
                "/signIn": (BuildContext context) => SignIn()
            },
            initialRoute: "/signIn",
            title: 'Flutter Demo',
            theme: ThemeData(
                // is not restarted.
                primarySwatch: Colors.blue,
            ),
            home: SignIn()),
    );

在所有示例代码中,他们在 MaterialApp 小部件的 "home" 下使用 Provider。我在提供程序中使用了 MaterialApp。

完全没问题。没有任何问题。