大家好,我正在尝试在代码中映射字符串列表,但它给了我错误“参数类型‘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)