[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The following assertion was thrown building NotificationListener<KeepAliveNotification>: Failed assertion: '_debugUltimatePreviousSiblingOf(after, equals: _firstChild)': is not true. #13581

Closed
silverAndroid opened this issue Dec 14, 2017 · 9 comments

Comments

@silverAndroid
Copy link
silverAndroid commented Dec 14, 2017

Steps to Reproduce

I'm not sure how to reproduce the issue with a smaller, simpler project but I'm trying to implement pagination in my application and I'm getting this error.

Project: Project which includes setup instructions for the SQLite DB

To hit the issue, all I have to do is scroll and when I hit the list item containing the ProgressBar, this happens. I think it may have something to do with the state being set once the query is complete and the list being reset but Flutter is expecting the row it was at but instead, it's brought back to the first row.

Logs

I/flutter ( 3048): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 3048): The following assertion was thrown building NotificationListener<KeepAliveNotification>:
I/flutter ( 3048): 'package:flutter/src/rendering/object.dart': Failed assertion: line 2700 pos 14:
I/flutter ( 3048): '_debugUltimatePreviousSiblingOf(after, equals: _firstChild)': is not true.
I/flutter ( 3048): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter ( 3048): more information in this error message to help you determine and fix the underlying cause.
I/flutter ( 3048): In either case, please report this assertion by filing a bug on GitHub:
I/flutter ( 3048):   https://github.com/flutter/flutter/issues/new
I/flutter ( 3048): When the exception was thrown, this was the stack:
I/flutter ( 3048): #2      RenderSliver&ContainerRenderObjectMixin._insertIntoChildList (package:flutter/src/rendering/object.dart:2700:14)
I/flutter ( 3048): #3      RenderSliver&ContainerRenderObjectMixin.insert (package:flutter/src/rendering/object.dart:2734:5)
I/flutter ( 3048): #4      RenderSliverMultiBoxAdaptor.insert (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:193:17)
I/flutter ( 3048): #5      SliverMultiBoxAdaptorElement.insertChildRenderObject (package:flutter/src/widgets/sliver.dart:840:18)
I/flutter ( 3048): #6      RenderObjectElement.attachRenderObject (package:flutter/src/widgets/framework.dart:4453:35)
I/flutter ( 3048): #7      RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4224:5)
I/flutter ( 3048): #8      SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4593:16)
I/flutter ( 3048): #9      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2920:14)
I/flutter ( 3048): #10     Element.updateChild (package:flutter/src/widgets/framework.dart:2723:12)
I/flutter ( 3048): #11     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #12     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #13     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3587:5)
I/flutter ( 3048): #14     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 3048): #15     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2920:14)
I/flutter ( 3048): #16     Element.updateChild (package:flutter/src/widgets/framework.dart:2723:12)
I/flutter ( 3048): #17     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #18     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #19     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3587:5)
I/flutter ( 3048): #20     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 3048): #21     ParentDataElement.mount (package:flutter/src/widgets/framework.dart:3900:16)
I/flutter ( 3048): #22     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2920:14)
I/flutter ( 3048): #23     Element.updateChild (package:flutter/src/widgets/framework.dart:2723:12)
I/flutter ( 3048): #24     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #25     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #26     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3587:5)
I/flutter ( 3048): #27     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3725:22)
I/flutter ( 3048): #28     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 3048): #29     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2920:14)
I/flutter ( 3048): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:2723:12)
I/flutter ( 3048): #31     SliverMultiBoxAdaptorElement.performRebuild (package:flutter/src/widgets/sliver.dart:696:34)
I/flutter ( 3048): #32     SliverMultiBoxAdaptorElement.update (package:flutter/src/widgets/sliver.dart:665:7)
I/flutter ( 3048): #33     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #34     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4323:32)
I/flutter ( 3048): #35     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4709:17)
I/flutter ( 3048): #36     _ViewportElement.update (package:flutter/src/widgets/viewport.dart:182:17)
I/flutter ( 3048): #37     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #38     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #39     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #40     ProxyElement.update (package:flutter/src/widgets/framework.dart:3854:5)
I/flutter ( 3048): #41     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #42     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4601:14)
I/flutter ( 3048): #43     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #44     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4601:14)
I/flutter ( 3048): #45     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #46     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4601:14)
I/flutter ( 3048): #47     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #48     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #49     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #50     StatefulElement.update (package:flutter/src/widgets/framework.dart:3744:5)
I/flutter ( 3048): #51     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #52     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4601:14)
I/flutter ( 3048): #53     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #54     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4601:14)
I/flutter ( 3048): #55     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #56     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4601:14)
I/flutter ( 3048): #57     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #58     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #59     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #60     StatelessElement.update (package:flutter/src/widgets/framework.dart:3669:5)
I/flutter ( 3048): #61     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #62     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #63     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #64     StatefulElement.update (package:flutter/src/widgets/framework.dart:3744:5)
I/flutter ( 3048): #65     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #66     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #67     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #68     StatefulElement.update (package:flutter/src/widgets/framework.dart:3744:5)
I/flutter ( 3048): #69     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #70     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #71     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #72     ProxyElement.update (package:flutter/src/widgets/framework.dart:3854:5)
I/flutter ( 3048): #73     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #74     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #75     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #76     StatelessElement.update (package:flutter/src/widgets/framework.dart:3669:5)
I/flutter ( 3048): #77     Element.updateChild (package:flutter/src/widgets/framework.dart:2712:15)
I/flutter ( 3048): #78     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3619:16)
I/flutter ( 3048): #79     Element.rebuild (package:flutter/src/widgets/framework.dart:3508:5)
I/flutter ( 3048): #80     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2257:33)
I/flutter ( 3048): #81     BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:627:20)
I/flutter ( 3048): #82     BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:200:5)
I/flutter ( 3048): #83     BindingBase&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:713:15)
I/flutter ( 3048): #84     BindingBase&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:649:9)
I/flutter ( 3048): #85     _invoke (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:113)
I/flutter ( 3048): #86     _drawFrame (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:102)
I/flutter ( 3048): (elided 2 frames from class _AssertionError)
I/flutter ( 3048): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/rendering/object.dart': Failed assertion: line 2700 pos 14: '_debugUltimatePreviousSiblingOf(after, equals: _firstChild)': is not true.
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/rendering/object.dart': Failed assertion: line 2700 pos 14: '_debugUltimatePreviousSiblingOf(after, equals: _firstChild)': is not true.
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/rendering/object.dart': Failed assertion: line 2700 pos 14: '_debugUltimatePreviousSiblingOf(after, equals: _firstChild)': is not true.
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
I/flutter ( 3048): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3510 pos 14: 'owner._debugCurrentBuildTarget == this': is not true.
I/flutter ( 3048): Another exception was thrown: The _ScaffoldLayout custom multichild layout delegate forgot to lay out the following children:
I/flutter ( 3048): Another exception was thrown: type 'RenderErrorBox' is not a subtype of type 'RenderSemanticsGestureHandler' of 'semanticsGestureHandler' where

Flutter Doctor

[✓] Flutter (on Linux, locale en_CA.UTF-8, channel alpha)
    • Flutter at /home/rushil/dev/SDK/flutter
    • Framework revision d957c8f040 (2 weeks ago), 2017-11-30 13:29:59 -0800
    • Engine revision 77d8acb9be
    • Tools Dart version 1.25.0-dev.11.0
    • Engine Dart version 2.0.0-dev.9.0

[✓] Android toolchain - develop for Android devices (Android SDK 26.0.2)
    • Android SDK at /home/rushil/dev/SDK/Android
    • Android NDK at /home/rushil/dev/SDK/Android/ndk-bundle
    • Unable to locate compiler in Android NDK.
      
    • Platform android-26, build-tools 26.0.2
    • ANDROID_HOME = /home/rushil/dev/SDK/Android
    • Java binary at: /home/rushil/Programs/android-studio-preview/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[✓] Android Studio (version 3.0)
    • Android Studio at /home/rushil/Programs/android-studio-preview
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[✓] Android Studio (version 3.0)
    • Android Studio at /home/rushil/Programs/android-studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[✓] IntelliJ IDEA Ultimate Edition (version 2017.3)
    • Flutter plugin version 19.1
    • Dart plugin version 173.3727.108

[✓] Connected devices
    • Google Nexus 6P, 6 0 0, API 23, 1440x2560 • 192.168.56.101:5555 • android-x86 • Android 6.0 (API 23)
@ganeshp0001
Copy link
ganeshp0001 commented Apr 24, 2018

For me error is comes when

  1. Parent widget has scrollable tabs, each containing different widgets contains forms, first tab contains widget containing form text boxes, and second tab has dropdown
  2. Click on text box and while keyboard appears, then scroll to second tab and click on drop down button.

This throws the error mentioned above.

@luoyushouchai
Copy link

For me error is comes when
1. Parent widget is ListView, which top widget is TextField! TextField has foucs on firstly, keyboard shows, then scroll page untill hide textField, trigger setState()! The error comes!

@vagrantrobbie
Copy link
vagrantrobbie commented Jun 7, 2018

I'm using a TabBarView and wanting to use a new instance of a Class for each view. I'm trying to pass variables to each instance to render a ListView.builder in the Class. It works for a short while but after calling setState I get the same error as above.

The only way I have been able to reliably get my view to work is by duplicating the class and creating a new instance of each. Very frustrating and time consuming

Flutter (Channel beta, v0.4.4, on Mac OS X 10.13.4 17E202, locale en-NZ)
flutter: The following assertion was thrown building NotificationListener<KeepAliveNotification>: flutter: 'package:flutter/src/rendering/object.dart': Failed assertion: line 2756 pos 14: flutter: '_debugUltimatePreviousSiblingOf(after, equals: _firstChild)': is not true. flutter: flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially flutter: more information in this error message to help you determine and fix the underlying cause. flutter: In either case, please report this assertion by filing a bug on GitHub: flutter: https://github.com/flutter/flutter/issues/new flutter:****

@Hixie
Copy link
Contributor
Hixie commented Jun 12, 2018

Duplicate of #11895.

@Hixie Hixie closed this as completed Jun 12, 2018
@WosLovesLife
Copy link

I get the similar problem when I use PageView, AutomaticKeepAliveClientMixin and BottomNavigationBar

I had a home screen like this:

class HomeScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
  List<NavigationIconView> _navigationViews;
  PageController _tabController;
  int pageIndex = 0;

  @override
  void initState() {
    super.initState();
    _tabController = new PageController(initialPage: pageIndex);
    _navigationViews = <NavigationIconView>[
      NavigationIconView(
        icon: const Icon(Icons.show_chart),
        title: '路线',
        page: HomeMainScreen(),
      ),
      NavigationIconView(
        icon: const Icon(Icons.group_work),
        title: '约伴',
        page: HomeTeamScreen(),
      ),
      NavigationIconView(
        icon: const Icon(Icons.book),
        title: '发现',
        page: TestScreen('发现'),
      ),
      NavigationIconView(
        icon: const Icon(Icons.settings),
        title: '设置',
        page: HomeMeScreen(),
      ),
    ];
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageView(
        controller: _tabController,
        physics: NeverScrollableScrollPhysics(),
        onPageChanged: (int index) {
          setState(() {
            this.pageIndex = index;
          });
        },
        children: _navigationViews
            .map((navigationView) => navigationView.page)
            .toList(),
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: _navigationViews
            .map((navigationView) => navigationView.item)
            .toList(),
        currentIndex: pageIndex,
        type: BottomNavigationBarType.fixed,
        onTap: (int index) => _tabController.jumpToPage(index),
      ),
    );
  }
}

In this code, HomeMainScreen and HomeTeamScreen are StatefulWidgets and the State extends from AutomaticKeepAliveClientMixin.

I used the following way to fix it.

first, added this code into the file where it Scaffold in.

class _BottomNavigationBarContainer extends StatefulWidget {
  final IndexedWidgetBuilder builder;
  final _BottomNavigationBarController controller;

  _BottomNavigationBarContainer(this.builder, this.controller);

  @override
  _BottomNavigationBarContainerState createState() => _BottomNavigationBarContainerState();
}

class _BottomNavigationBarContainerState extends State<_BottomNavigationBarContainer> {
  @override
  void initState() {
    super.initState();

    widget.controller.addListener(_onIndexChanged);
  }

  @override
  void didUpdateWidget(_BottomNavigationBarContainer oldWidget) {
    super.didUpdateWidget(oldWidget);

    if (oldWidget.controller != widget.controller) {
      oldWidget.controller.removeListener(_onIndexChanged);
      widget.controller.addListener(_onIndexChanged);
    }
  }

  @override
  void dispose() {
    widget.controller.removeListener(_onIndexChanged);
    super.dispose();
  }

  _onIndexChanged() => setState(() {});

  @override
  Widget build(BuildContext context) {
    return widget.builder(context, widget.controller.index);
  }
}

class _BottomNavigationBarController extends Listenable {
  int _currentIndex = 0;

  _BottomNavigationBarController({int initialIndex = 0}) : _currentIndex = initialIndex;

  setIndex(int index) {
    if (index == _currentIndex) return;
    _currentIndex = index;
    _notification();
  }

  get index {
    return _currentIndex;
  }

  List<VoidCallback> listeners = [];

  @override
  void addListener(listener) {
    listeners.add(listener);
  }

  @override
  void removeListener(listener) {
    listeners.remove(listener);
  }

  _notification() {
    listeners.map((listener) {
      listener();
    });
  }
}

and then build bottomNavigationBar like the following:

bottomNavigationBar: _BottomNavigationBarContainer((BuildContext context, int index) {
      return BottomNavigationBar(
        items: _navigationViews.map((navigationView) => navigationView.item).toList(),
        currentIndex: index,
        type: BottomNavigationBarType.fixed,
        onTap: (int index) {
          _tabController.jumpToPage(index);
        },
      );
    }, _bottomNavigationBarController),

@zoechi
Copy link
Contributor
zoechi commented Aug 21, 2018

There are open issues with similar errors
https://github.com/flutter/flutter/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+_debugUltimatePreviousSiblingOf

This one is closed since a while. If none of the open issues matches your problem it's probably better to create a new issue.

@pickupsb
Copy link
pickupsb commented Oct 9, 2018

@WosLovesLife

你解决了吗

@WosLovesLife
Copy link

@pickupsb 解决了, 我忘了这个问题是怎么引起的了. 我的解决方式就是在 原先的 BottomNavigationBar 外面套了一层 我自己写的 _BottomNavigationBarController 看我上面的代码. _BottomNavigationBarContainer有一个_bottomNavigationBarController控制器, 在PageView的onPageChanged回调时调用_bottomNavigationBarController. setIndex()

@github-actions
Copy link
github-actions bot commented Sep 1, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants