为什么 Scaffold 在 Android 中没有填充屏幕底部?
我是颤振新手。我的屏幕没有其他任何东西——只有一个脚手架。不知道为什么,它没有填满整个屏幕。
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: MyHomePage(),
),
);
}
class MyHomePage extends StatefulWidget {
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void _incrementCounter() {
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.green,
);
}
}
I am new to Flutter. My screen don't have anything else - only a scaffold. I don't know why, it is not filling the entire screen.
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: MyHomePage(),
),
);
}
class MyHomePage extends StatefulWidget {
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void _incrementCounter() {
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.green,
);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这是因为底部区域是 Android 导航栏的一部分,因此您需要显式更改其背景:
有关更多信息,请检查 文档。
I think this is because the bottom area is a part of the Android navigation bar, hence you need to change the background of it explicitly:
For more information, check the documentation.
您应该考虑使用 SafeArea Widget,它用于覆盖或不覆盖屏幕的顶部和底部:
https://api.flutter.dev/flutter/widgets/SafeArea-class。 html
底部是你关心的:
它知道当前上下文 MediaQuery 和 View Padding
You should consider using the SafeArea Widget, it's used to cover the top and bottom of the screen or not :
https://api.flutter.dev/flutter/widgets/SafeArea-class.html
The bottom is what you care :
It's aware of the current context MediaQuery and the View Padding