Flutter ParentDataWidget的使用不正确。颤振应用程序
我在这个问题上纠缠了很长时间 我不知道怎么修,请帮忙 它说灵活,而我没有使用灵活的小部件。 我只使用了expanded,即使我删除了expanded widget,仍然会出现同样的错误 此外,我还试图删除除列表视图生成器小部件以外的所有内容,但收到相同的错误 代码如下:Flutter ParentDataWidget的使用不正确。颤振应用程序,flutter,flutter-design,Flutter,Flutter Design,我在这个问题上纠缠了很长时间 我不知道怎么修,请帮忙 它说灵活,而我没有使用灵活的小部件。 我只使用了expanded,即使我删除了expanded widget,仍然会出现同样的错误 此外,我还试图删除除列表视图生成器小部件以外的所有内容,但收到相同的错误 代码如下: import 'package:flutter/material.dart'; import 'package:todoy/Colors.dart'; import 'Taskslistview.dart'; import '
import 'package:flutter/material.dart';
import 'package:todoy/Colors.dart';
import 'Taskslistview.dart';
import 'TasksListTile.dart';
import 'package:provider/provider.dart';
import 'Helper.dart';
bool isChekec = false;
class TasksScreen extends StatelessWidget {
Widget buildsheet(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Colors.white,
),
height: 400,
child: Padding(
padding: EdgeInsets.only(left: 50.0, right: 50),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(
height: 10,
),
Center(
child: Text(
'Add Task',
style: TextStyle(
fontSize: 30,
color: Provider.of<Helper>(context).choosedcolor),
)),
TextField(
decoration: InputDecoration(
helperStyle: TextStyle(color: Colors.red),
helperText: Provider.of<Helper>(context).alreadyexist
? "this task already exist"
: " "),
textAlign: TextAlign.center,
onChanged: (value) {
if (Provider.of<Helper>(context, listen: false)
.tasknames
.contains(value)) {
Provider.of<Helper>(context, listen: false)
.alreadyture();
} else {
Provider.of<Helper>(context, listen: false)
.alreadyfalse();
}
Provider.of<Helper>(context, listen: false)
.addtaskname(value);
Provider.of<Helper>(context, listen: false)
.addtaskname(value);
print(Provider.of<Helper>(context, listen: false)
.addedtask);
},
),
SizedBox(
height: 10,
),
Container(
height: 50,
// ignore: deprecated_member_use
child: FlatButton(
color: Provider.of<Helper>(context).choosedcolor,
onPressed: () {
if (Provider.of<Helper>(context, listen: false)
.alreadyexist) {
print("you cant");
} else if (Provider.of<Helper>(context, listen: false)
.addedtask ==
"") {
print("ffgg");
} else {
Provider.of<Helper>(context, listen: false).addname(
Provider.of<Helper>(context, listen: false)
.addedtask);
Provider.of<Helper>(context, listen: false)
.add(TasksListTile(
isChcked: isChekec,
nameofthetask:
Provider.of<Helper>(context, listen: false)
.addedtask,
));
Provider.of<Helper>(context, listen: false)
.addedtask = "";
Navigator.pop(context);
}
},
child: Text(
"ADD",
style: TextStyle(color: Colors.white, fontSize: 20),
)),
)
],
),
),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Provider.of<Helper>(context).choosedcolor,
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.only(left: 300.0, top: 30, right: 15),
child: GestureDetector(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => ColorsScreen()));
},
child: CircleAvatar(
radius: 35,
backgroundColor: Colors.white,
child: Icon(
Icons.invert_colors,
size: 40,
color: Provider.of<Helper>(context).choosedcolor,
)),
),
),
Padding(
padding: EdgeInsets.only(left: 40.0, top: 40),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CircleAvatar(
radius: 35,
backgroundColor: Colors.white,
child: Icon(
Icons.list,
size: 40,
color: Provider.of<Helper>(context).choosedcolor,
)),
Padding(
padding: const EdgeInsets.only(right: 30.0),
child: Container(
height: 67,
child: FittedBox(
child: FloatingActionButton(
child: Icon(Icons.delete_forever,
size: 40,
color: Provider.of<Helper>(context)
.choosedcolor),
backgroundColor: Colors.white,
onPressed: () {
Provider.of<Helper>(context, listen: false)
.remove();
},
),
),
),
),
],
),
),
Padding(
padding: EdgeInsets.only(top: 8.0, left: 10, bottom: 10),
child: Text(
"Todoy",
style: TextStyle(color: Colors.white, fontSize: 40),
textAlign: TextAlign.start,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
' ${Provider.of<Helper>(context).tasks.length} Tasks',
style: TextStyle(color: Colors.white, fontSize: 40),
textAlign: TextAlign.start,
),
Padding(
padding: const EdgeInsets.only(right: 30.0),
child: Container(
height: 70,
child: FittedBox(
child: FloatingActionButton(
child: Text(
"+",
style: TextStyle(
fontSize: 50,
color: Provider.of<Helper>(context)
.choosedcolor),
),
backgroundColor: Colors.white,
onPressed: () {
showModalBottomSheet(
context: context, builder: buildsheet);
},
),
),
),
),
],
),
],
),
),
SizedBox(
height: 20,
),
Expanded(
child: Container(
padding: EdgeInsets.only(left: 20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40),
topRight: Radius.circular(40))),
child: Taskslistview(),
),
),
],
),
),
);
}
}
导入“包装:颤振/材料.省道”;
导入“package:todoy/Colors.dart”;
导入“Taskslistview.dart”;
导入“TasksListTile.dart”;
导入“包:provider/provider.dart”;
导入“Helper.dart”;
bool-isChekec=false;
类taskscreen扩展了无状态小部件{
小部件构建表(构建上下文){
返回SingleChildScrollView(
子:列(
儿童:[
容器(
装饰:盒子装饰(
颜色:颜色,白色,
),
身高:400,
孩子:填充(
填充:仅限边缘设置(左:50.0,右:50),
子:列(
crossAxisAlignment:crossAxisAlignment.stretch,
儿童:[
大小盒子(
身高:10,
),
居中(
子:文本(
“添加任务”,
样式:TextStyle(
尺寸:30,
颜色:Provider.of(context.choosedcolor),
)),
文本字段(
装饰:输入装饰(
helperStyle:TextStyle(颜色:Colors.red),
helperText:Provider.of(context).alreadyexist
?“此任务已存在”
: " "),
textAlign:textAlign.center,
一旦更改:(值){
if(Provider.of(context,listen:false)
.任务名称
.包含(值)){
Provider.of(上下文,侦听:false)
.alreadyture();
}否则{
Provider.of(上下文,侦听:false)
.alreadyfalse();
}
Provider.of(上下文,侦听:false)
.addtaskname(值);
Provider.of(上下文,侦听:false)
.addtaskname(值);
打印(Provider.of)(上下文,侦听:false)
.补充任务);
},
),
大小盒子(
身高:10,
),
容器(
身高:50,
//忽略:不推荐的\u成员\u使用
孩子:扁平按钮(
颜色:Provider.of(上下文)。选择颜色,
已按下:(){
if(Provider.of(context,listen:false)
(alreadyexist先生){
打印(“你不能”);
}else if(Provider.of(context,listen:false)
.补充质询==
"") {
印刷品(“ffgg”);
}否则{
Provider.of(context,listen:false).addname(
Provider.of(上下文,侦听:false)
.补充任务);
Provider.of(上下文,侦听:false)
.add(任务列表)(
Ischeked:isChekec,
任务名称:
Provider.of(上下文,侦听:false)
.补充质询:,
));
Provider.of(上下文,侦听:false)
.addedtask=“”;
Navigator.pop(上下文);
}
},
子:文本(
“添加”,
样式:TextStyle(颜色:Colors.white,字体大小:20),
)),
)
],
),
),
),
],
),
);
}
@凌驾
小部件构建(构建上下文){
返回材料PP(
家:脚手架(
backgroundColor:Provider.of(context).choosedcolor,
正文:专栏(
crossAxisAlignment:crossAxisAlignment.stretch,
儿童:[
填充物(
填充:仅限常量边集(左:300.0,上:30,右:15),
儿童:手势检测器(
onTap:(){
Navigator.push(上下文,
MaterialPage路由(生成器:(上下文)=>ColorsScreen());
},
孩子:圆环星(
class Taskslistview extends StatelessWidget {
@override
Widget build(BuildContext context) {
bool isChecked = false;
return ListView.builder(
itemCount: Provider.of<Helper>(context).tasks.length,
itemBuilder: (context, index) {
return TasksListTile(
isChcked: isChecked,
nameofthetask:
Provider.of<Helper>(context, listen: false).tasknames[index],
);
},
);
}
}