【发布时间】:2021-08-10 19:22:08
【问题描述】:
我正在尝试将列表中的引号设置为文本小部件,但我遇到了这个问题
参数类型“List
这是我的代码
import 'package:flutter/material.dart';
void main() {
runApp(myApp());
}
class myApp extends StatefulWidget {
@override
_myAppState createState() => _myAppState();
}
class _myAppState extends State<myApp> {
List<String> quotesList = [
"The secret of getting ahead is getting started",
"Only the paranoid survive",
"It’s hard to beat a person who never gives up.",
"Never Had luck never needed it"
];
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.black38,
title: Text("Quotes"),
),
body: Column(
children: [quotesList.map((e) => Text(e))].toList(),
),
),
);
}
}
【问题讨论】:
-
只需删除子项中的 [],就像这样子项:quotesList.map((e) => Text(e)).toList(),
-
在First Lettre中类名应该是大写,myApp => MyApp :)