[英]List of buttons using ListTile Flutter
I am getting an error while trying to compile my code could anyone help me fix it?我在尝试编译我的代码时遇到错误,任何人都可以帮助我修复它吗? I am trying to create a list of buttons that will navigate to another screen.
我正在尝试创建一个将导航到另一个屏幕的按钮列表。 It was previously a expansion tile and I am trying to switch it to a list tile.
它以前是一个扩展图块,我正在尝试将其切换为列表图块。
return ListTile(
title: Text(StudyViewModel.studies[index].name,
style: TextStyle(fontSize: 18.0)),
children: <Widget>[
ListView.builder(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
itemCount: StudyViewModel.studies[index].tasks.length,
itemBuilder: (context, int taskIndex) {
return ListTile(
title: Text(StudyViewModel.studies[index].tasks[taskIndex].name),
contentPadding: EdgeInsets.symmetric(horizontal: 32.0),
subtitle: Text(
StudyViewModel.studies[index].tasks[taskIndex].elapsedTime),
);
},
),
Based off of responses, the goal of this code is to create a list of buttons that have previously been defined in a template.根据响应,此代码的目标是创建一个以前在模板中定义的按钮列表。 These buttons will be used in a time study app.
这些按钮将用于时间研究应用程序。 I would like to be able to upload the activities into a new page.
我希望能够将活动上传到新页面。 Originally, the code was written as an expansiontile, but I am trying to change it to a listtile.
最初,代码是作为扩展块编写的,但我正在尝试将其更改为列表块。 The error we are encountering is:
我们遇到的错误是:
lib/pages/home_page.dart:107:7: Error: No named parameter with the name 'children'. lib/pages/home_page.dart:107:7: 错误:没有名为“children”的命名参数。 children: [ ^^^^^^^^../../lib/flutter/packages/flutter/lib/src/material/list_tile.dart:762:9: Context: Found this candidate, but the arguments don't match.
孩子们:[ ^^^^^^^^../../lib/flutter/packages/flutter/lib/src/material/list_tile.dart:762:9: 上下文:找到这个候选人,但 arguments 不匹配。 const ListTile({ ^^^^^^^^ Failed to compile application
const ListTile({ ^^^^^^^^ 编译应用失败
The ListTile widget doesn't contain a parameter named children. ListTile 小部件不包含名为 children 的参数。 In your code you're setting a parameter 'children' which is invalid.
在您的代码中,您设置的参数“children”无效。
This might help:这可能会有所帮助:
return ListView(
children: <Widget>[
Text(StudyViewModel.studies[index].name,
style: TextStyle(fontSize: 18.0),
),
ListView.builder(
shrinkWrap: true,
primary: false,
itemCount: StudyViewModel.studies[index].tasks.length,
itemBuilder: (context, int taskIndex) {
return ListTile(
title: Text(StudyViewModel.studies[index].tasks[taskIndex].name),
contentPadding: EdgeInsets.symmetric(horizontal: 32.0),
subtitle: Text(StudyViewModel.studies[index].tasks[taskIndex].elapsedTime),
);
},
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.