Flutter中使用Column中白屏问题
Posted Xiao冰同学
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter中使用Column中白屏问题相关的知识,希望对你有一定的参考价值。
日常开发中Column出现白屏
记录平时Flutter项目开发中的一些问题
@override
Widget build(BuildContext context)
return Scaffold(
appBar: AppBarLeftTitle(
title: '选择数据',
rightWidget: ButtonCommon(
margin: EdgeInsets.symmetric(horizontal: 10.0),
text: '返回上一级',
fontSize: 12.0,
width: 80,
height: 30,
color: ColorHelper.linkBlue,
circular: 5.0,
onTap: ()
),
),
body: SingleChildScrollView(
child: Column(
children: [
Expanded(
child: CupertinoScrollbar(
child: ListView(
children: [
GestureDetector(
onTap: () ,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
color: Colors.white,
height: 46,
padding: EdgeInsets.symmetric(horizontal: 15),
child: Row(
children: <Widget>[
TextCommon('测试', size: 14, color: Colors.black),
Spacer(),
TextCommon('测试', size: 14, color: Color(0xFFCCCCCC))
],
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 15),
child: DividerHorizontal(),
),
],
),
)
]
)
)
)
],
)
),
);
结果运行报错,关键错误提示如下
======== Exception caught by rendering library ===================================================== The following assertion was thrown during paint(): RenderBox was not laid out:
RenderRepaintBoundary#6c4b0 relayoutBoundary=up1 NEEDS-PAINT
‘package:flutter/src/rendering/box.dart’: Failed assertion: line 1785
pos 12: ‘hasSize’Either the assertion indicates an error in the framework itself, or we
should provide substantially more information in this error message to
help you determine and fix the underlying cause. In either case,
please report this assertion by filing a bug on GitHub
其实就是外面的SingleChildScrollView与里面的Column的ListView出现了冲突,所以要想解决这个问题,去掉外面的SingleChildScrollView即可
以上是关于Flutter中使用Column中白屏问题的主要内容,如果未能解决你的问题,请参考以下文章
Flutter Web:白屏(PersistedOffset 错误)
FlutterFlutter 启动白屏问题 ( 问题描述 | 在 launch_background.xml 中设置启动过渡 UI )