class View1 extends StatelessWidget {
const View1({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "View1",
home: Scaffold(
appBar: AppBar(title: Text('View2'),),
body: Center(child: Text('View2'),),
floatingActionButton: ElevatedButton(onPressed: () =>
Navigator.push(context,
MaterialPageRoute(builder: (context) => View2()
)
),
),
),
);
}
}
class View2 extends StatelessWidget {
const View2({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "View1",
home: Scaffold(
appBar: AppBar(title: Text('View2'),),
body: Center(child: Text('View2'),),
),
);
}
}
▸ この snippet は実行結果未収録
▸ 実行結果は未収録です
Source収録記事
この snippet は記事の「戻るボタンが表示されなかったコードは下記」セクションに登場する。コードの前後の文脈・ハマりどころの解説は記事本文で。
