ParentDataWidget 的错误使用。颤振应用程序

时间:2021-04-21 03:31:06

标签: flutter flutter-design

我被这个问题困扰了很长时间

in debug console

我不知道怎么解决,请帮忙 它说灵活,而我没有使用灵活的小部件。 我只使用了扩展,即使我删除了扩展的小部件仍然有同样的错误 我还尝试删除除列表视图构建器小部件之外的所有内容,但我仍会收到相同的错误

这是代码:

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(),
                      ),
                    ),
                  ],
                ),
              ),
            );
          }
        }

在任务列表视图中:

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],
        );
      },
    );
  }
}

请帮助我尝试了一切修复它没有任何效果

0 个答案:

没有答案