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

标签 flutter dart

我需要使用脚手架,这样我才能使用抽屉,但我还需要使用导航器。这是我到目前为止所拥有的,但不确定如何在家里使用脚手架?

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?
      ),
    ));
  }
}

最佳答案

我可能有一个解决方案,但我不知道它会有多大帮助。

我喜欢打电话

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
    },
  ));
}
}

您可以在需要时调用电话:
Navigator.pushNamed(context,'/login');

关于flutter - 是否可以使用脚手架和导航器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62030526/

相关文章:

Firebase 云消息传递报告错误

dart - 在 Flutter 中使用 iOS 行为时更改 ListView 反弹颜色

flutter - 如何在Cloud Firestore的CollectionReference中添加DocumentID?使用 flutter

_formKey.currentState.validate() 上的 Flutter/Dart Null 安全性?

mobile - Flutter 换屏回调

Flutter - 删除实时 Firebase 数据 onTap()

dart - 如何在 build.dart 构建后运行命令?

Flutter如何在同一张 map 中添加2个标记

flutter - Dart const 作为预处理器指令

Dart - 如何使用不同的主体进行多个 http.post 请求