网站上有一些类似的问题,但我无法准确弥补
Widget _buildBody(tab) {
return BlocBuilder(
bloc: _lessonsBloc,
builder: (BuildContext context, LessonsState state) { //HERE
if (state is LessonsLoading) {
return Center(
child: CircularProgressIndicator(),
);
} else if (state is LessonsLoaded) {
return ListView.builder(
itemCount: state.lessons.length,
itemBuilder: (context, index) {
final displayedLessons = state.lessons[index];
return ListTile(
title: Text(displayedLessons.name),
subtitle:Text(displayedLessons.subname),
trailing: _buildUpdateDeleteButtons(displayedLessons),
);
},
);
}
},
);
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码,我在 builder 所在的标题中收到警告。
如果有人提供解决方案或想法,我将不胜感激:)
如果我在 DartPad 中编写,print(DateTime.parse("2012-12-12"));它会起作用。那么为什么当我执行以下操作时它不起作用(它报告“无效的日期格式”):
for (int i = 1; i <= 28; i = i + 7) {
_activities[DateTime.parse('2012-12-$i')] = activityNames.toList();
}
Run Code Online (Sandbox Code Playgroud) 我在下面有一个标签栏,如 Tab (text: '') 和 _tabcontroller,如果我使用 tab.text 作为正文其工作良好 (body:Text(tab.text)) 但如果我为索引创建一个列表并使用 exampleList[_tabcontroller .index] 它的速度很慢,就像我在刷屏一样,它等待 1 秒。我的代码比我发布的要大,但我认为这是我的核心问题。n:我想使用 Tab 之类的 Tab(child:Row()) 所以我不能使用 tab.text 如果它有其他选择我也可以(idk tab.listener 或 tab.id?)
TabController _tabController;
final List<Tab> tabs = <Tab>[
new Tab(text: "hello1",),
new Tab(text:"hello2"),
];
...
@override
void initState() {
super.initState();
_tabController = new TabController(
vsync: this, length: tabs.length, initialIndex: cDate);
_tabController.addListener(_handleSelected);
}
void _handleSelected() {
setState(() {
_tabController.index;
});
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
...
body: new TabBarView(
controller: _tabController,
children: tabs.map((Tab tab) { …Run Code Online (Sandbox Code Playgroud)