我正在实现一个定制的应用程序栏,我希望在action: [] Widget中向AppBar属性添加可选的小部件。但是,当我在action小部件列表中插入小部件时,我会得到一个错误,上面写着The element type 'Widget?'can't be assigned to the list type 'Widget'
我想要创建一个可选的小部件,以便在action属性中插入AppBar。extends StatelessWidget implements Prefe
(我的理论是因为扩展运算符会将输出转换为列表,所以.toList不会对字符串执行anything...like调用.toString。)如果我删除扩展运算符并保留.toList(),我会得到错误"type List<dynamic> is not a subtype of type Widget"。(这使我的理论无效,扩散运算符和.toList具有相同的效果)
我读到前面提到的错误是由于类型推断,并看到建议将<Widget>紧跟在.map后面,如下所示:snapshot.data