對於non-material app,你可以將center
widget加到app的build()
method裡面,但由於這是用non-material寫出來的,所以app bar、標題、背景要自己創建,不過這反而可以客製化更多app裡面的widget
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(color: Colors.white),
child: const Center(
child: Text(
'Hello World',
textDirection: TextDirection.ltr,
style: TextStyle(
fontSize: 32,
color: Colors.black87,
),
),
),
);
}
}
參考資料:
https://docs.flutter.dev/development/ui/layout