我正在制作一个基本的购物应用程序。我的想法是制作我的产品的列表图块,以便我可以编辑或删除产品。因此,当我导航到该页面时,它显示了一个空白的白色页面,并出现如图所示的错误 空白屏幕 错误
import 'package:flutter/material.dart';
class UserProductItem extends StatelessWidget {
final String title;
final String imageUrl;
UserProductItem(this.title, this.imageUrl);
@override
Widget build(BuildContext context) {
return ListTile(
title: Text(title),
leading: CircleAvatar(
backgroundImage: NetworkImage(imageUrl),
),
trailing: Row(
children: [
IconButton(
icon: Icon(Icons.edit),
onPressed: () {},
color: Theme.of(context).primaryColor,
),
IconButton(
icon: Icon(Icons.delete),
onPressed: () {},
color: Theme.of(context).errorColor,
)
],
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
cva*_*eek 23
我也遇到了这个问题,并且能够通过设置来mainAxisSize修复它:MainAxisSize.minRow
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: Icon(Icons.edit),
onPressed: () {},
color: Theme.of(context).primaryColor,
),
IconButton(
icon: Icon(Icons.delete),
onPressed: () {},
color: Theme.of(context).errorColor,
)
],
),
Run Code Online (Sandbox Code Playgroud)
The*_*uad 20
用trailing a 包裹Container可能会给您某种警告,因此最好的选择是用 awrap包裹SizedBox并给它 aheight和width
trailing: SizedBox(
height: 100, width: 100, child: Image.network(item.imgurl)),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16775 次 |
| 最近记录: |