zoukankan      html  css  js  c++  java
  • InheritedWidget

    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return RootWidget(
          child: MaterialApp(
            debugShowCheckedModeBanner: false,
            title: 'V2EX app',
            theme: ThemeData(
              primarySwatch: Colors.grey,
            ),
            initialRoute: '/',
            routes: {
              '/': (context) => HomePage(),
              '/nodes': (context) => NodePage(),
              '/test': (context) => TestApp(),
    //          '/web': (context) => WebTest(),
            },
          ),
          bloc: UserBloc(),
        );
      }
    }
    

      

    class RootWidget extends InheritedWidget {
      RootWidget({this.bloc, this.child}) : super(child: child);
      final UserBloc bloc;
      final Widget child;
    
      static RootWidget of(BuildContext context) =>
          (context).inheritFromWidgetOfExactType(RootWidget);
    
      @override
      bool updateShouldNotify(InheritedWidget oldWidget) {
        return true;
      }
    }
    

      

  • 相关阅读:
    【KMP】Period
    【KMP】Cyclic Nacklace
    【KMP】Oulipo
    【KMP】Number Sequence
    二分
    Stock 贪心经典 Zoj2921
    D. Block Tower
    烦人的dp
    搜索
    hdu 一个人的旅行
  • 原文地址:https://www.cnblogs.com/pythonClub/p/10695598.html
Copyright © 2011-2022 走看看