我有这个新闻 API,它获取最新的新闻更新,但即使我有一个项目“itemCount”的长度,我的列表视图也会给我一个错误。
我在 Itemcount 上尝试了“_total.length”,但它给了我一个错误。
尝试导入定义 'length' 的库,将名称更正为现有 getter 的名称,或定义名为 'length' 的 getter 或字段。
class _NewsUpdateState extends State<NewsUpdate> {
List _bottomItems =
[
{"icon": FontAwesomeIcons.fire, "index": 0},
{"icon": FontAwesomeIcons.moneyBillAlt, "index": 1},
{"icon": FontAwesomeIcons.bell, "index": 2},
{"icon": FontAwesomeIcons.futbol, "index": 3},
];
String _apiKey = '46d80623786da4a97847da2b6cd7747';
int _currentTab = 0;
String _apiUrl = '';
int _total = 0;
List _articles = [];
bool _loading = true;
@override
void initState() {
super.initState();
changeTab(index: 0);
}
void changeTab({int index = 0}) {
//tab1 is …Run Code Online (Sandbox Code Playgroud)