简体   繁体   English

是否可以使用脚手架和导航器?

[英]Is it possible to use a Scaffold and navigator?

I need to use a scaffold so I can use a drawer, but I also need to use a navigator.我需要使用脚手架,这样我才能使用抽屉,但我还需要使用导航器。 Here is what I have so far, but not sure how to use Scaffold in the home spot?这是我到目前为止所拥有的,但不确定如何在家里使用脚手架?

void main() {
  setupLocator();
  runApp(new App());
}

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle.dark.copyWith(statusBarColor: Colors.transparent),
    );

    return LifeCycleManager(
        child: MaterialApp(
      builder: (context, widget) => SafeArea(
        child: Navigator(
          onGenerateRoute: Router.generateRoute,
          initialRoute: routes.RegisterRoute,
        ),
        top: true,
        bottom: true,
        left: false,
        right: false,
        // title: 'Register',
        // home: OnBoardingPage(), <-- probably where my scaffold should go but using initialRoute above?
      ),
    ));
  }
}

I might have a solution but I don t know how helpful it would be.我可能有一个解决方案,但我不知道它会有多大帮助。

I like to call我喜欢打电话

void main() async {
//staff I want to do before app starts
//maybe I want to call something saved in phone memory or idk,mabye this
 SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle.dark.copyWith(statusBarColor: Colors.transparent),
    );

  Widget _defaultHome = new IntroScreen();
//I recommend this because you can make some tests before

runApp(new MaterialApp(
 home: defaultHome,//or call direct the page you want
    routes: <String, WidgetBuilder>{
//routes
  '/login': (BuildContext context) => new MyLoginPage(),//example
    },
  ));
}
}

You will be able to call when you need:您可以在需要时拨打电话:

Navigator.pushNamed(context,'/login');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM