Flutter を勉強し始めた。
そこで少しハマったところを覚え書きとして記載しておく。
下記のコードでも両方動作する。
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Sample Page'),
),
),
);
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample Page'),
),
);
}
上記2つは動作するのだが、その違いは大きい。例えば、前画面から上記のページを下記にて呼んだ場合、前者はナビゲータバーの戻るボタンが表示されない。つまり、ページのスタックに積まれるのはAppレベルではないため階層が異なる。
Navigator.push(context, MaterialPageRoute(builder: (context) => NextPage()));
少しづつだが理解を深めたいと思う。