【发布时间】:2021-08-25 19:50:28
【问题描述】:
我是新来的,在传递字符串时遇到错误,到处查看,最后在 StackOverflow 中添加了这个
错误是
Error: The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't.
void errorSnackBar(BuildContext context, String? text) {
ScaffoldMessenger.of(context).showSnackBar(new SnackBar(
duration: new Duration(seconds: 4),
content: new Row(
children: <Widget>[
Icon(
Icons.error,
color: Colors.red,
),
Padding(
padding: const EdgeInsets.fromLTRB(10.0, 0, 0, 0),
child: new Text(text),
),
],
),
));
}
【问题讨论】:
标签: flutter android-studio dart visual-studio-code flutter-layout