部署 Web 应用程序时,Flutter Web 在使用 singleChildScrollView 时显示空白
Flutter web showing blank on using singleChildScrollView when deploying web app
Flutter web 在使用 debug 模式时不显示任何错误,但在发布时显示黑屏。
代码如下:
class _AboutUsState extends State<AboutUs> {
@override
Widget build(BuildContext context) {
var height = MediaQuery.of(context).size.height;
var width = MediaQuery.of(context).size.width;
var pad = EdgeInsets.only(top: height * 0.15);
return Scaffold(
appBar: AppBar(
leading: IconButton(
onPressed: () => Navigator.pop(context),
icon: Icon(
Icons.arrow_back,
color: Colors.grey,
)),
backgroundColor: Colors.grey[50],
title: Text(\ widget here
),
),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(left: width * 0.1, right: width * 0.1),
child: Column(
children: [
// widgets here ],
)
],
),
),
));
}
}
我也附上了一张图片。
我认为那是空白,因为您没有为列表视图定义任何高度。
要使用列表视图,您应该定义它的宽度和高度。
为了测试,尝试用容器包裹它并给它高度和宽度。
return
Container(
width:500,
height:1000,
child: Listview(
children:[childA(),childB,etc()]));
Flutter web 在使用 debug 模式时不显示任何错误,但在发布时显示黑屏。
代码如下:
class _AboutUsState extends State<AboutUs> {
@override
Widget build(BuildContext context) {
var height = MediaQuery.of(context).size.height;
var width = MediaQuery.of(context).size.width;
var pad = EdgeInsets.only(top: height * 0.15);
return Scaffold(
appBar: AppBar(
leading: IconButton(
onPressed: () => Navigator.pop(context),
icon: Icon(
Icons.arrow_back,
color: Colors.grey,
)),
backgroundColor: Colors.grey[50],
title: Text(\ widget here
),
),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(left: width * 0.1, right: width * 0.1),
child: Column(
children: [
// widgets here ],
)
],
),
),
));
}
}
我也附上了一张图片。
我认为那是空白,因为您没有为列表视图定义任何高度。
要使用列表视图,您应该定义它的宽度和高度。 为了测试,尝试用容器包裹它并给它高度和宽度。
return
Container(
width:500,
height:1000,
child: Listview(
children:[childA(),childB,etc()]));