【发布时间】:2018-04-03 20:19:32
【问题描述】:
我在 Column 小部件的顶部有一个图像,之后有一个标题是 Text 小部件,之后,还有一个 Text 小部件包含一些描述并且超出了屏幕并给出了呈现错误。
所以我想让那个文本视图可以滚动,这样它就应该完全可见并且也可以滚动。并且它的大小必须是动态的,因为来自 API 的数据。 我尝试了几种方法,但无法完成。 这是截图
截图:
@override
Widget build(BuildContext context) {
var size = MediaQuery
.of(context)
.size;
final double itemHeight = (size.height - kToolbarHeight - 24) / 2;
final double itemWidth = size.width;
return new Container(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Padding(
padding: const EdgeInsets.fromLTRB(0.0, 24.0, 0.0, 0.0),
child: new Image.asset(
'assets/img/noconnection.png',
height: 200.0,
width: itemWidth,
),
),
new Padding(
padding: const EdgeInsets.all(12.0),
child: new Text(
"Some Heading Text",
style: new TextStyle(
fontSize: 28.0,
color: Colors.black87,
fontWeight: FontWeight.w600),
),
),
new SingleChildScrollView(
child: new Text(
"Description that is too long in text format(Here Data is coming from API)",
style: new TextStyle(
fontSize: 16.0, color: Colors.black87,
),
),
),
],
),
);
}
【问题讨论】:
-
new SingleChildScrollView( child: new Text( "描述文本格式太长", style: new TextStyle( fontSize: 16.0, color: Colors.black87, ), ), ), 改变了上面代码列中的第三个孩子......但不工作:(
-
你能用新的格式化代码更新问题吗?
-
@RaoufRahiche 更新了代码 ...
标签: scroll flutter scrollable