简体   繁体   English

断言失败:第 6292 行第 12 行:'child == _child':不是真的

[英]Failed assertion: line 6292 pos 12: 'child == _child': is not true

I am a beginner in flutter and I am facing this issue currently that I am not even sure how to solve or what it is about.我是 flutter 的初学者,我目前正面临这个问题,我什至不确定如何解决或它是关于什么的。 all I know for sure is that it's happening in tasks_list.dart and nothing else.我所知道的只是它发生在 tasks_list.dart 中,没有别的。 I would appreciate it if someone can explain it to me.如果有人能向我解释,我将不胜感激。 thank you.谢谢你。

import 'package:flutter/material.dart';
import 'package:todo_list/util/task_tile.dart';

import '../models/task.dart';

class TasksList extends StatelessWidget {
  const TasksList({
    Key? key,
    required this.tasksList,
  }) : super(key: key);

  final List<Task> tasksList;

  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: SingleChildScrollView(
        child: ExpansionPanelList.radio(
          children: tasksList
              .map(
                (task) => ExpansionPanelRadio(
                  value: task.id,
                  headerBuilder: (context, isOpen) => TaskTile(task: task),
                  body: ListTile(
                    title: SelectableText.rich(
                      TextSpan(
                        children: [
                          const TextSpan(
                            text: 'Task\n',
                            style: TextStyle(fontWeight: FontWeight.bold),
                          ),
                          TextSpan(text: task.title),
                          const TextSpan(
                            text: '\n\nDescription\n',
                            style: TextStyle(fontWeight: FontWeight.bold),
                          ),
                          TextSpan(text: task.description),
                        ],
                      ),
                    ),
                  ),
                ),
              )
              .toList(),
        ),
      ),
    );
  }
}

This is the pending task screen.这是待定任务屏幕。 it seems that wherever the task_list is used it's showing the same error.似乎无论在哪里使用 task_list,它都会显示相同的错误。 I have no clue why to be honest.我不知道为什么要说实话。

import 'package:flutter/material.dart';
import 'package:todo_list/screens/timer_screen.dart';
import 'package:todo_list/util/home_screen_appbar.dart';
import 'package:todo_list/util/my_drawer.dart';
import 'package:todo_list/util/tasks_list.dart';

import '../../blocs/bloc_exports.dart';
import '../../blocs/tasks_bloc/tasks_bloc.dart';
import '../../blocs/tasks_bloc/tasks_state.dart';
import '../../models/task.dart';
import '../add_task_screen.dart';

class TodoListScreen extends StatefulWidget {
  const TodoListScreen({Key? key}) : super(key: key);

  @override
  State<TodoListScreen> createState() => _TodoListScreenState();
}

class _TodoListScreenState extends State<TodoListScreen> {
  void _addTask(BuildContext context) {
    showModalBottomSheet(
      backgroundColor: Theme.of(context).primaryColor,
      context: context,
      isScrollControlled: true,
      builder: (context) => SingleChildScrollView(
        padding: EdgeInsets.only(
          bottom: MediaQuery.of(context).viewInsets.bottom,
        ),
        child: const AddTaskScreen(),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<TasksBloc, TasksState>(
      builder: (context, state) {
        List<Task> tasksList = state.pendingTasks;
        return Scaffold(
          appBar: HomeScreenAppBar(
            appBarTitle: 'T O D O',
            icon: Icons.timer,
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => const TimerScreen(),
                ),
              );
            },
          ),
          floatingActionButton: FloatingActionButton(
            elevation: 6.0,
            onPressed: () => _addTask(context),
            backgroundColor: Theme.of(context).cardColor,
            child: const Icon(Icons.add, color: Colors.white),
          ),
          drawer: const MyDrawer(),
          body: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Center(
                child: Chip(
                  label: Text(
                      '${state.pendingTasks.length} Pending  | ${state.completedTasks.length} Completed'),
                ),
              ),
              TasksList(tasksList: tasksList)
            ],
          ),
        );
      },
    );
  }
}

This is the error log concerning the issue.这是有关该问题的错误日志。

======== Exception caught by widgets library =======================================================
The following assertion was thrown building RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#d42d2](state: RawGestureDetectorState#3f499(gestures: <none>, behavior: opaque)):
All ExpansionPanelRadio identifier values must be unique.
'package:flutter/src/material/expansion_panel.dart':
Failed assertion: line 263 pos 14: '_allIdentifiersUnique()'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

The relevant error-causing widget was: 
  SingleChildScrollView SingleChildScrollView:file:///C:/Users/LENOVO/Flutter%20Dev/Apps/todo_list/lib/util/tasks_list.dart:17:14
When the exception was thrown, this was the stack: 
#2      _ExpansionPanelListState.initState (package:flutter/src/material/expansion_panel.dart:263:14)
#3      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5015:57)
#4      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4853:5)
...     Normal element mounting (97 frames)
#101    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3863:16)
#102    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6435:36)
#103    MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6447:32)
...     Normal element mounting (25 frames)
#128    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3863:16)
#129    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6435:36)
#130    MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6447:32)
...     Normal element mounting (113 frames)
#243    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (291 frames)
#534    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3863:16)
#535    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6435:36)
#536    MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6447:32)
...     Normal element mounting (407 frames)
#943    _InheritedProviderScopeElement.mount (package:provider/src/inherited_provider.dart:411:11)
...     Normal element mounting (7 frames)
#950    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (7 frames)
#957    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (7 frames)
#964    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3863:16)
#965    Element.updateChild (package:flutter/src/widgets/framework.dart:3592:18)
#966    RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1195:16)
#967    RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1164:5)
#968    RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:1111:18)
#969    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2605:19)
#970    RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1110:13)
#971    WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:945:7)
#972    WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:925:7)
(elided 13 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
====================================================================================================

Edited Version编辑版本

class TasksList extends StatelessWidget {
  const TasksList({
    Key? key,
    required this.tasksList,
  }) : super(key: key);

  final List<Task> tasksList;

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: ExpansionPanelList.radio(
        children: tasksList
            .map(
              (task) => ExpansionPanelRadio(
                value: task.id,
                headerBuilder: (context, isOpen) => TaskTile(task: task),
                body: ListTile(
                  title: SelectableText.rich(
                    TextSpan(
                      children: [
                        const TextSpan(
                          text: 'Task\n',
                          style: TextStyle(fontWeight: FontWeight.bold),
                        ),
                        TextSpan(text: task.title),
                        const TextSpan(
                          text: '\n\nDescription\n',
                          style: TextStyle(fontWeight: FontWeight.bold),
                        ),
                        TextSpan(text: task.description),
                      ],
                    ),
                  ),
                ),
              ),
            )
            .toList(),
      ),
    );
  }
}

Error Log错误日志

======== Exception caught by widgets library =======================================================
The following assertion was thrown building RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#7a212](state: RawGestureDetectorState#9c2fd(gestures: <none>, behavior: opaque)):
All ExpansionPanelRadio identifier values must be unique.
'package:flutter/src/material/expansion_panel.dart':
Failed assertion: line 263 pos 14: '_allIdentifiersUnique()'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

The relevant error-causing widget was: 
  SingleChildScrollView SingleChildScrollView:file:///C:/Users/LENOVO/Flutter%20Dev/Apps/todo_list/lib/util/tasks_list.dart:16:12
When the exception was thrown, this was the stack: 
#2      _ExpansionPanelListState.initState (package:flutter/src/material/expansion_panel.dart:263:14)
#3      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5015:57)
#4      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4853:5)
...     Normal element mounting (91 frames)
#95     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3863:16)
#96     MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6435:36)
#97     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6447:32)
...     Normal element mounting (25 frames)
#122    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3863:16)
#123    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6435:36)
#124    MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6447:32)
...     Normal element mounting (113 frames)
#237    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (291 frames)
#528    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3863:16)
#529    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6435:36)
#530    MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6447:32)
...     Normal element mounting (407 frames)
#937    _InheritedProviderScopeElement.mount (package:provider/src/inherited_provider.dart:411:11)
...     Normal element mounting (7 frames)
#944    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (7 frames)
#951    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (7 frames)
#958    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3863:16)
#959    Element.updateChild (package:flutter/src/widgets/framework.dart:3592:18)
#960    RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1195:16)
#961    RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1164:5)
#962    RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:1111:18)
#963    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2605:19)
#964    RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1110:13)
#965    WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:945:7)
#966    WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:925:7)
(elided 13 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
====================================================================================================

======== Exception caught by rendering library =====================================================
The following assertion was thrown during layout:
A RenderFlex overflowed by 99272 pixels on the bottom.

The relevant error-causing widget was: 
  Column Column:file:///C:/Users/LENOVO/Flutter%20Dev/Apps/todo_list/lib/screens/task_type_screens/pending_screen.dart:60:17
The overflowing RenderFlex has an orientation of Axis.vertical.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.

The specific RenderFlex in question is: RenderFlex#a23bb relayoutBoundary=up1 OVERFLOWING
...  needs compositing
...  parentData: offset=Offset(0.0, 90.7); id=_ScaffoldSlot.body (can use size)
...  constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=775.6)
...  size: Size(411.4, 775.6)
...  direction: vertical
...  mainAxisAlignment: start
...  mainAxisSize: max
...  crossAxisAlignment: center
...  verticalDirection: down
◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
====================================================================================================

You need to remove Expanded widget.您需要删除扩展小部件。 And Follow this pattern.并遵循这种模式。

As for the chat section, rebuilding the app after this resolve the issue.至于聊天部分,在此问题解决后重建应用程序。


class TasksList extends StatelessWidget {
  const TasksList({
    Key? key,
    required this.tasksList,
  }) : super(key: key);

  final List tasksList;

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: ExpansionPanelList.radio(
        children: tasksList
            .map(
              (task) => ExpansionPanelRadio(
                value: task,
                headerBuilder: (context, isOpen) => Text("A"),
                body: ListTile(
                  title: SelectableText.rich(
                    TextSpan(
                      children: [
                        const TextSpan(
                          text: 'Task\n',
                          style: TextStyle(fontWeight: FontWeight.bold),
                        ),
                        TextSpan(text: " task.title"),
                        const TextSpan(
                          text: '\n\nDescription\n',
                          style: TextStyle(fontWeight: FontWeight.bold),
                        ),
                        TextSpan(text: "task.description"),
                      ],
                    ),
                  ),
                ),
              ),
            )
            .toList(),
      ),
    );
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 失败的断言:第 6075 行 pos 12:&#39;child == _child&#39;:不是真的 - Failed assertion: line 6075 pos 12: 'child == _child': is not true 断言行 5120 pos 12 失败:'child = _child' 不是真的 - Failed assertion line 5120 pos 12: 'child = _child' is not true 失败的断言:第 549 行 pos 12:“child.hasSize”:不正确 - Failed assertion: line 549 pos 12: 'child.hasSize': is not true 失败的断言:第 551 行 pos 12:“child.hasSize”:不正确 - Failed assertion: line 551 pos 12: 'child.hasSize': is not true Flutter - _AssertionError('package:flutter/src/widgets/framework.dart':断言失败:第 4937 行 pos 12:'child == _child':不正确。) - Flutter - _AssertionError ('package:flutter/src/widgets/framework.dart': Failed assertion: line 4937 pos 12: 'child == _child': is not true.) Error 断言失败:第 5143 行第 16 行:'孩子是! 父数据元素<parentdata> ':不是真的</parentdata> - Failed assertion: line 5143 pos 16: 'child is! ParentDataElement<ParentData>': is not true 失败的断言:第 1696 行 pos 12:&#39;center!.parent == this&#39;:不是真的 - Failed assertion: line 1696 pos 12: 'center!.parent == this': is not true 断言失败:第 184 行 pos 12:'end &gt;= begin':不正确 - Failed assertion: line 184 pos 12: 'end >= begin': is not true 断言失败:第 1205 行第 12 行:'<optimized out> ':不是真的</optimized> - Failed assertion: line 1205 pos 12: '<optimized out>': is not true Flutter 应用程序因“断言失败:第 4901 行 pos 16:'child is! ParentDataElement 而死<parentdata> ':不是真的。”</parentdata> - Flutter App dies with "Failed assertion: line 4901 pos 16: 'child is! ParentDataElement<ParentData>': is not true."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM