将我的小部件放到Flutter的专栏中会破坏一切
为了锻炼自己,我正在尝试重新创建IMDb应用程序。我这样做是为了学习尽可能地密切关注一些事情,以学习让事情看起来像它们应该的样子。列中的列变得相当复杂,我不确定我是否做错了什么,但它是这样工作的(请告诉我,如果我的代码根本上是错的) 我尝试了很多方法,甚至在代码中有空列,下面的文本和按钮,它工作得很好(如中所示,按钮在文本旁边,而不是应该在下面,但不会崩溃) 被许多人包围的部分是“问题区域”,我不知道上下文需要什么将我的小部件放到Flutter的专栏中会破坏一切,flutter,widget,flutter-layout,Flutter,Widget,Flutter Layout,为了锻炼自己,我正在尝试重新创建IMDb应用程序。我这样做是为了学习尽可能地密切关注一些事情,以学习让事情看起来像它们应该的样子。列中的列变得相当复杂,我不确定我是否做错了什么,但它是这样工作的(请告诉我,如果我的代码根本上是错的) 我尝试了很多方法,甚至在代码中有空列,下面的文本和按钮,它工作得很好(如中所示,按钮在文本旁边,而不是应该在下面,但不会崩溃) 被许多人包围的部分是“问题区域”,我不知道上下文需要什么 卡片( 颜色:(HSVColor.fromAHSV(1.0,0.0,0.0,
卡片(
颜色:(HSVColor.fromAHSV(1.0,0.0,0.0,0.22)).toColor(),
子项:列(子项:[
堆叠(
儿童:[
沙德尔马斯克(
着色器回调:(rect){
返回线半径(
开始:Alignment.topCenter,
结束:对齐。底部中心,
颜色:[颜色。黑色,颜色。透明],
).createShader(
垂直于LTRB(0,200,垂直宽度,垂直高度);
},
blendMode:blendMode.dstIn,
子级:Image.asset(“资产/电影/”+
_movie.getImagePath()+
“/banner1.bmp”),
),
对齐(
对齐:分馏loffset.bottomLeft,
孩子:填充(
填充:仅限边缘设置(底部:10.0),
子项:列(子项:[
RichText(
textAlign:textAlign.left,
text:TextSpan(
文本:_movie.getName()+'\n\n',
风格:
TextStyle(颜色:Colors.white,字体大小:25),
儿童:[],
),
),
]),
),
)
],
),
对齐(
对齐:对齐。左下角,
子:文本(
“\n”+
_movie.getReleaseYear()+
" " +
_movie.getDuration().toString()+
“由以下人员指导的分钟:”+
_movie.getDirector(),
textAlign:textAlign.left,
样式:TextStyle(颜色:Colors.white70)),
填充物(
填充:所有边缘设置(7.0),
),
划船(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
影像资产(
“资产/电影/”+
_movie.getImagePath()+
“/poster.bmp”,
身高:240,
宽度:160),
填充物(
填充:所有边缘设置(4.0),
),
/////////////////////////////////////////////////////
纵队(
儿童:[],
),
扩大(
子对象:对齐(
对齐:alignment.topLeft,
子:文本(
_movie.getDescription(),
样式:TextStyle(颜色:Colors.white),
))),
升起的按钮(
按下:(){},
textColor:Colors.white,
颜色:颜色,蓝色,
)
/////////////////////////////////////////////////////
],
)
])),
正如您可能看到的,我在这里所做的只是将展开的and按钮拖放到列中
卡(
颜色:(HSVColor.fromAHSV(1.0,0.0,0.0,0.22)).toColor(),
子项:列(子项:[
堆叠(
儿童:[
沙德尔马斯克(
着色器回调:(rect){
返回线半径(
开始:Alignment.topCenter,
结束:对齐。底部中心,
颜色:[颜色。黑色,颜色。透明],
).createShader(
垂直于LTRB(0,200,垂直宽度,垂直高度);
},
blendMode:blendMode.dstIn,
子级:Image.asset(“资产/电影/”+
_movie.getImagePath()+
“/banner1.bmp”),
),
对齐(
对齐:分馏loffset.bottomLeft,
孩子:填充(
填充:仅限边缘设置(底部:10.0),
子项:列(子项:[
RichText(
textAlign:textAlign.left,
text:TextSpan(
文本:_movie.getName()+'\n\n',
风格:
TextStyle(颜色:Colors.white,字体大小:25),
儿童:[],
),
),
]),
),
)
],
),
对齐(
对齐:对齐。左下角,
子:文本(
“\n”+
_movie.getReleaseYear()+
" " +
_movie.getDuration().toString()+
“由以下人员指导的分钟:”+
_movie.getDirector(),
textAlign:textAlign.left,
样式:TextStyle(颜色:Colors.white70)),
填充物(
填充:所有边缘设置(7.0),
),
划船(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
影像资产(
“资产/电影/”+
_movie.getImagePath()+
“/poster.bmp”,
身高:240,
宽度:160),
填充物(
填充:所有边缘设置(4.0),
),
/////////////////////////////////////////////////////
栏(儿童:[
扩大(
子对象:对齐(
对齐:alignment.topLeft,
子:文本(
_movie.getDescription(),
样式:TextStyle(颜色:Colors.white),
))),
升起的按钮(
onPr
════════ (2) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#46c16 relayoutBoundary=up10 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Column file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:28:22
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (3) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#1ecab relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (4) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#bf879 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (5) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#23d9c relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (6) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: _RenderInkFeatures#d5fb8 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (7) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderCustomPaint#c42f6 relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (8) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderPhysicalShape#af491 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (9) Exception caught by rendering library ═════════════════════════════════════════════════
RenderBox was not laid out: RenderPadding#82ff0 relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (10) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#d9b34 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Scaffold file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:12:12
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (11) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#f2c36 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Scaffold file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:12:12
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (12) Exception caught by rendering library ════════════════════════════════════════════════
The method '>' was called on null.
Receiver: null
Tried calling: >(1e-10)
User-created ancestor of the error-causing widget was:
Scaffold file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:12:12
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (13) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#1ecab relayoutBoundary=up9 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (14) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#bf879 relayoutBoundary=up8 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (15) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#23d9c relayoutBoundary=up7 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (16) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: _RenderInkFeatures#d5fb8 relayoutBoundary=up6 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (17) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: RenderCustomPaint#c42f6 relayoutBoundary=up5 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (18) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: RenderPhysicalShape#af491 relayoutBoundary=up4 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (19) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: RenderPadding#82ff0 relayoutBoundary=up3 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Card file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:26:11
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (20) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#d9b34 relayoutBoundary=up2 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Scaffold file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:12:12
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (21) Exception caught by rendering library ════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#f2c36 relayoutBoundary=up1 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was:
Scaffold file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:12:12
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ (22) Exception caught by rendering library ════════════════════════════════════════════════
The method '>' was called on null.
Receiver: null
Tried calling: >(1e-10)
User-created ancestor of the error-causing widget was:
Scaffold file:///C:/Users/xxx/dev/flutter_testapp2/lib/movie_detailed_widget.dart:12:12
════════════════════════════════════════════════════════════════════════════════════════════════════
Card(
color: (HSVColor.fromAHSV(1.0, 0.0, 0.0, 0.22)).toColor(),
child: Column(children: <Widget>[
Stack(
children: <Widget>[
ShaderMask(
shaderCallback: (rect) {
return LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.black, Colors.transparent],
).createShader(
Rect.fromLTRB(0, 200, rect.width, rect.height));
},
blendMode: BlendMode.dstIn,
child: Image.network('https://placeimg.com/640/480/tech'),
),
Align(
alignment: FractionalOffset.bottomLeft,
child: Padding(
padding: EdgeInsets.only(bottom: 10.0),
child: Column(children: <Widget>[
RichText(
textAlign: TextAlign.left,
text: TextSpan(
text: 'Dummy Movie' + '\n\n',
style: TextStyle(color: Colors.white, fontSize: 25),
children: <TextSpan>[],
),
),
]),
),
)
],
),
Align(
alignment: Alignment.bottomLeft,
child: Text(
"\n " +
'2019' +
" " +
'2h 30 Min' +
"min Directed by: " +
'Anmol Majhail',
textAlign: TextAlign.left,
style: TextStyle(color: Colors.white70))),
Padding(
padding: EdgeInsets.all(7.0),
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Image.network(
'https://placeimg.com/640/480/tech',
height: 240,
width: 160,
alignment: Alignment.topCenter,
),
Padding(
padding: EdgeInsets.all(4.0),
),
/////////////////////////////////////////////////////
Flexible(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: Text(
'This is Dummy Description. Just to fill up the space.',
style: TextStyle(color: Colors.white),
)),
RaisedButton(
onPressed: () {},
textColor: Colors.white,
color: Colors.blue,
)
],
),
),
/////////////////////////////////////////////////////
],
)
]))