flutter 错误 : The argument type 'Object?' can't be assigned to the parameter type 'String'

标签 flutter dart

所以我开始学习 dart 和 flutter,在观看一些类(class)时我遇到了这个错误。是否在 flutter 中更改了某些内容,为什么它不起作用?另外,如果我没有附上需要的东西,我很抱歉,我是这个世界上的新人。谢谢!

error part

Column (
    children: [

  Pytanie(
    pytania[_indekspytan]['tekstPytan'],
  ),

and here is the whole column

Column(

children: [

  Pytanie(
    pytania[_indekspytan]['tekstPytan'], 
  ),

  ...(pytania[_indekspytan]['odpowiedzi'] as List<String> ).map((odpowiedz)   { //kropki zapobiegaja tworzeniu 2 listy, podmienia wartosci

    return Odpowiedz(_odpowiedzi,  odpowiedz);

  }).toList()


],



),

最佳答案

使用 toString() 怎么样

Pytanie(
    pytania[_indekspytan]['tekstPytan']?.toString() ?? ''
),

关于 flutter 错误 : The argument type 'Object?' can't be assigned to the parameter type 'String' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66749996/

相关文章:

android - Flutter中如何从外部存储获取文件?

datetime - 如何到达 Dart 的最后一个午夜?

flutter - 如何在 Flutter 中使用 ScopedModel 时保留数据?

ios - 无法使用 PathProvider 依赖项构建 flutter 项目

flutter - 在复选框选择屏幕上使用Navigator.pop时,如何在其他屏幕上显示列表?

firebase - 为什么初始值不更新和显示?

static - 是否可以使用 Dart 执行静态代码?

dart - 在Dart中可以定义类似的声明 `GroupByIterator<TSource, Grouping<TKey, TElement>>`吗

android - 谷歌云端硬盘同意屏幕卡住

android - 如何在 Dart 帖子请求中发送数组