Flutter/画面遷移
提供: 初心者エンジニアの簡易メモ
目次
画面遷移サンプル
その1
routerをMyAppの中に追加
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(title: 'Flutter Demo Home Page'), routes: <String, WidgetBuilder> { '/help': (BuildContext context) => new MyHomePage(title: 'page help'), '/privacy': (BuildContext context) => new MyHomePage(title: 'page privacy'), '/use': (BuildContext context) => new MyHomePage(title: 'page use'), }, ); } }
画面遷移
Navigator.of(context).pushNamed('/use');
その2
router&画面遷移
Navigator.push(context, new MaterialPageRoute<Null>( settings: const RouteSettings(name: "/use"), builder: (BuildContext context) => MyHomePage(title: 'page use') ));