flutter - 如何将数据传递给颤振应用程序中的类
问题描述
我正在尝试将数据传递给flutter中的一个类,但由于此错误而失败,我不知道如何调试它,我是flutter的新手:
errors.dart:187 Uncaught (in promise) 错误:无效参数:未找到提要
我怎么知道它找不到哪个提要?
我尝试遵循此方法,但 ity 不起作用。这是我的 main.dart 代码:
void main() async {
final AtomFeed feed = await RssService().getFeed();
runApp(Start(feed));
}
class Start extends StatelessWidget {
final AtomFeed feed;
Start(this.feed);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DefaultTabController(
length: 5,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: [
Tab(text: 'First', icon: Icon(Icons.music_note)),
Tab(text: 'Second', icon: Icon(Icons.music_video)),
],
),
title: Text('Start'),
backgroundColor: Colors.green,
),
body: TabBarView(
children: [
First(this.feed),
MyHomePage(title: 'Wowzers!'),
],
),
),
),
);
}
}
然后在第一:
class First extends StatelessWidget {
final AtomFeed feed;
First(this.feed);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('RSS'),
),
body: ListView.builder(
itemCount: this.feed.items.length,
itemBuilder: (BuildContext ctxt, int index) {
final item = this.feed.items[index];
return ListTile(
title: Text(item.title),
subtitle: Text('Published at ' +
DateFormat.yMd().format(DateTime.parse(item.published))),
contentPadding: EdgeInsets.all(16.0),
onTap: () async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WebViewContainer(
item.id.replaceFirst('http', 'https'))));
},
);
}),
);
}
}
解决方案
我将所有 feed 变量重命名为 feed1、feed2 等。问题不在于我的任何变量,而在于 rss 服务的方法。
推荐阅读
- amazon-redshift - 参数名称 系统视图中缺少信息 PG_PROC_INFO.proargnames 用于未命名的参数
- java - 如何替换两个数字之间的每个空格?
- bash - 无法从 Bash 脚本安装 Windows 服务
- oauth - 来自命令行的三足 OAuth 令牌
- html - 滚动导航栏右侧透明?
- firebase - 如何按当前日期从 Cloud Firestore 获取数据?
- angular - 服务和构建命令的 Angular CLI 问题
- php - 用年份 php 对数组进行排序
- .net-core - 与连接到现有总线的消费者一起阅读消息
- xaml - 如何将这三个按钮放在底部的中心?