Flutter 如何使用flatter在snackbar中放置图标
我是个新手,我不知道是否可以这样做。我想在文本的左侧放置一个图标Flutter 如何使用flatter在snackbar中放置图标,flutter,Flutter,我是个新手,我不知道是否可以这样做。我想在文本的左侧放置一个图标 SnackBar( backgroundColor: Colors.red, content: Text(_accion_toast + ". " + mensaje), duration: Duration(milliseconds: 1500), ); 您可以将SnackBar的内容参数更改为首先包含图标,然后包含文本的行。例如: SnackBar( backgroundColor: Colo
SnackBar(
backgroundColor: Colors.red,
content: Text(_accion_toast + ". " + mensaje),
duration: Duration(milliseconds: 1500),
);
您可以将SnackBar的内容参数更改为首先包含图标,然后包含文本的行。例如:
SnackBar(
backgroundColor: Colors.red,
content: Row(
children: <Widget>[
//Icon widget of your choice HERE,
Text(_accion_toast + ". " + mensaje)
]
),
duration: Duration(milliseconds: 1500),
);
Snackbar的content属性接受一个小部件
在您的情况下,您可以传递Row小部件,因为您希望将项目与图标和文本并排放置
检查下面的代码,它工作正常:
SnackBar(
// background color of your snack-bar
backgroundColor: Colors.red,
// make the content property take a Row
content: Row(
children: <Widget>[
// add your preferred icon here
Icon(
Icons.close,
color: Colors.white,
),
// add your preferred text content here
Text(_accion_toast + ". " + mensaje),
],
),
// the duration of your snack-bar
duration: Duration(milliseconds: 1500),
);
}