小编dam*_*esh的帖子

参数类型“Iterable<dynamic>”无法分配给参数类型“List<Widget>”

大家好,我正在尝试在代码中映射字符串列表,但它给了我错误“参数类型‘Iterable’不能分配给参数类型‘List’。”。我正在尝试重现下图中的结果。这是下面的代码;

**quote.dart**

class Quote {

  String? text;
  String? author;

  
 

  
  Quote({ required this.text,required this.author });

}


**main.dart**

void main() {
  runApp(MaterialApp(home: QuoteList()));
}

class QuoteList extends StatefulWidget {
  const QuoteList({Key? key}) : super(key: key);

  @override
  State<QuoteList> createState() => _QuoteListState();
}

class _QuoteListState extends State<QuoteList> {

  @override
  List<dynamic> quotes = [
    //"Quote" is the the name of the class of the second dart file.
    Quote(
        author: "Eminem",
        text:
            "You better lose yourself in music the moment you own it never let it …
Run Code Online (Sandbox Code Playgroud)

dart flutter fluttermap

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

dart ×1

flutter ×1

fluttermap ×1