Flutter 如何在颤振加载时变灰?
我是个新手 我想创建一种人员列表。 加载时,照片和文本应为灰色 这是我的密码Flutter 如何在颤振加载时变灰?,flutter,dart,flutter-layout,flutter-web,Flutter,Dart,Flutter Layout,Flutter Web,我是个新手 我想创建一种人员列表。 加载时,照片和文本应为灰色 这是我的密码 final List<Map<String, dynamic>> listItems = [ { 'name': 'AAA', 'img': '../assets/images/sample.jpg', 'comment': 'comment here', 'grade': 'VIP', 'age': '22', }, { 'name': 'BBB', 'img':
final List<Map<String, dynamic>> listItems = [
{
'name': 'AAA',
'img': '../assets/images/sample.jpg',
'comment': 'comment here',
'grade': 'VIP',
'age': '22',
},
{
'name': 'BBB',
'img': '../assets/images/sample.jpg',
'comment': 'comment here',
'grade': 'VIP',
'age': '22',
},
{
'name': 'CCC',
'img': '../assets/images/sample.jpg',
'comment': 'comment here',
'grade': 'VIP',
'age': '22',
},
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
//Stuff List
Container(
height: 250,
padding: EdgeInsets.only(bottom: 15.0),
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: listItems.length,
itemBuilder: (context, index) {
//Card
return FlatButton(
child: SizedBox(
width: 150,
child: Card(
color: Colors.grey,
child: Column(
children: [
//Photo
Stack(
overflow: Overflow.visible,
children: [
Container(
height: 180,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'../assets/images/sample.jpg'),
fit: BoxFit.cover,
),
),
),
//icon
Positioned(
bottom: -9.0,
right: 0.0,
child: Container(
width: 18,
height: 18,
child: Stack(
overflow: Overflow.visible,
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
),
Align(
alignment: Alignment.center,
child: Container(
width: 12,
height: 12,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.yellow,
),
),
),
],
)),
),
],
),
//Texts
Container(
padding: EdgeInsets.all(6.0),
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
margin: EdgeInsets.only(right: 10.0),
child: Text(
listItems[index]['name'],
style: TextStyle(
color: Colors.black87,
fontSize: 11,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.left,
),
),
Text(
listItems[index]['age'],
style: TextStyle(
color: Colors.black87,
fontSize: 11,
),
textAlign: TextAlign.left,
),
],
),
Text(
listItems[index]['comment'],
style: TextStyle(
color: Colors.black87,
fontSize: 11,
),
textAlign: TextAlign.left,
),
],
),
)
],
),
)),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CastProfileDetail(),
));
},
);
},
),
),
],
),
);}
最终列表项=[
{
“名称”:“AAA”,
“img”:“../assets/images/sample.jpg”,
'评论':'评论在这里',
“等级”:“VIP”,
"年龄":"22",,
},
{
'name':'BBB',
“img”:“../assets/images/sample.jpg”,
'评论':'评论在这里',
“等级”:“VIP”,
"年龄":"22",,
},
{
“名称”:“CCC”,
“img”:“../assets/images/sample.jpg”,
'评论':'评论在这里',
“等级”:“VIP”,
"年龄":"22",,
},
@凌驾
小部件构建(构建上下文){
返回容器(
子:列(
儿童:[
//材料清单
容器(
身高:250,
填充:仅限边缘设置(底部:15.0),
子项:ListView.builder(
滚动方向:轴水平,
itemCount:listItems.length,
itemBuilder:(上下文,索引){
//卡片
返回按钮(
孩子:大小盒子(
宽度:150,
孩子:卡片(
颜色:颜色。灰色,
子:列(
儿童:[
//照片
堆叠(
溢出:溢出。可见,
儿童:[
容器(
身高:180,
装饰:盒子装饰(
图像:装饰图像(
图片:资产评估(
“../assets/images/sample.jpg”),
适合:BoxFit.cover,
),
),
),
//图标
定位(
底部:-9.0,
右:0.0,
子:容器(
宽度:18,
身高:18,
子:堆栈(
溢出:溢出。可见,
儿童:[
容器(
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色,白色,
),
),
对齐(
对齐:对齐.center,
子:容器(
宽度:12,
身高:12,
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色,黄色,
),
),
),
],
)),
),
],
),
//文本
容器(
填充:所有边缘设置(6.0),
宽度:double.infinity,
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
划船(
儿童:[
容器(
边距:仅限边集(右:10.0),
子:文本(
listItems[索引]['name'],
样式:TextStyle(
颜色:颜色。黑色87,
尺寸:11,
fontWeight:fontWeight.bold,
),
textAlign:textAlign.left,
),
),
正文(
listItems[索引]['age'],
样式:TextStyle(
颜色:颜色。黑色87,
尺寸:11,
),
textAlign:textAlign.left,
),
],
),
正文(
listItems[索引]['comment'],
样式:TextStyle(
颜色:颜色。黑色87,
尺寸:11,
),
textAlign:textAlign.left,
),
],
),
)
],
),
)),
已按下:(){
导航器。推(
上下文
材料路线(
生成器:(上下文)=>CastProfileDetail(),
));
},
);
},
),
),
],
),
);}
我可以将物品列表显示为卡片,但我不知道如何从灰色方块切换到卡片。我只是尝试在卡片上设置颜色
如何在加载时将其灰显?您可以尝试