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

🐛 Scrollbar This widget has been unmounted, so the State no longer has a context (and should be considered defunct). #71

Closed
slimyjimmy opened this issue Sep 21, 2021 · 10 comments · Fixed by #279
Labels
blocked Issue blocked by another issue or pull-request bug Something isn't working

Comments

@slimyjimmy
Copy link

I get the following error message using a NavigationBody (which contains two views):

The following assertion was thrown during a scheduler callback:
This widget has been unmounted, so the State no longer has a context (and should be considered defunct).

Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.
When the exception was thrown, this was the stack:
#0 State.context. (package:flutter/src/widgets/framework.dart:909:9)
#1 State.context (package:flutter/src/widgets/framework.dart:915:6)
#2 RawScrollbarState._maybeTriggerScrollbar. (package:flutter/src/widgets/scrollbar.dart:1236:98)
#3 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1143:15)
#4 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1088:9)
#5 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:996:5)
#9 _invoke (dart:ui/hooks.dart:166:10)
#10 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:270:5)
#11 _drawFrame (dart:ui/hooks.dart:129:31)
(elided 3 frames from dart:async)

To be honest, I'm a little baffled. The error seems to be related to the NavigationBody (since I don't get the error when using a regular Material Scaffold). I tried adding AutomaticKeepAliveClientMixins to the views of the NavigationBody but that didn't help.

Have any of you ever experienced something similar?

@bdlukaa bdlukaa added the bug Something isn't working label Sep 21, 2021
@bdlukaa
Copy link
Owner

bdlukaa commented Sep 21, 2021

This issue is happening since I ever implemented scrollbars. It happens when we resize the window I think.

Tho, this is a Flutter issue. It happens on RawScrollbar

@NicolaVerbeeck
Copy link
Contributor

Seems like it is fixed on the flutter master branch

@TerryLiu
Copy link

I met the same problem

@YehudaKremer
Copy link
Contributor

same here.

  1. clone repo
  2. debug example:
    image

@WinXaito
Copy link
Collaborator

Seems to be fixed with:

child: Scrollbar(
  controller: pane.scrollController ?? ScrollController(),
  ...
)

At these lines:

https://github.com/bdlukaa/fluent_ui/blob/master/lib/src/controls/navigation/navigation_view/pane.dart#L340
https://github.com/bdlukaa/fluent_ui/blob/master/lib/src/controls/navigation/navigation_view/pane.dart#L464
https://github.com/bdlukaa/fluent_ui/blob/master/lib/src/controls/navigation/navigation_view/pane.dart#L583

But after that, I've the following error (only at the changement compact -> open and open -> compact, otherwise when I resize the window I don't have any errors.

======== Exception caught by scheduler library =====================================================
The following assertion was thrown during a scheduler callback:
The Scrollbar's ScrollController has no ScrollPosition attached.

A Scrollbar cannot be painted without a ScrollPosition. 

The Scrollbar attempted to use the provided ScrollController. This ScrollController should be associated with the ScrollView that the Scrollbar is being applied to. When providing your own ScrollController, ensure both the Scrollbar and the Scrollable widget use the same one.

When the exception was thrown, this was the stack: 
#0      RawScrollbarState._debugCheckHasValidScrollPosition.<anonymous closure> (package:flutter/src/widgets/scrollbar.dart:1285:9)
#1      RawScrollbarState._debugCheckHasValidScrollPosition (package:flutter/src/widgets/scrollbar.dart:1310:6)
#2      RawScrollbarState._maybeTriggerScrollbar.<anonymous closure> (package:flutter/src/widgets/scrollbar.dart:1242:16)
#3      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1143:15)
#4      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1088:9)
#5      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:996:5)
#9      _invoke (dart:ui/hooks.dart:166:10)
#10     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:270:5)
#11     _drawFrame (dart:ui/hooks.dart:129:31)
(elided 3 frames from dart:async)
====================================================================================================

@bdlukaa
Copy link
Owner

bdlukaa commented Dec 3, 2021

flutter/flutter#92657 seems to have fixed it. Tho it might take a while to land on stable

@bdlukaa bdlukaa added the blocked Issue blocked by another issue or pull-request label Dec 3, 2021
@bdlukaa
Copy link
Owner

bdlukaa commented Dec 9, 2021

flutter/flutter#82573

@jonahzheng
Copy link

it is fixed on the flutter master branch.

flutter channel master

@WinXaito
Copy link
Collaborator

@bdlukaa what about this ?

I got that with TabView... :(

@shiwenwang
Copy link

@bdlukaa what about this ?

I got that with TabView... :(

me too, so what's the solution for TabView?

flutter version: 2.10.5
fluent_ui version: 3.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Issue blocked by another issue or pull-request bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants