File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1447,6 +1447,9 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
14471447 }
14481448
14491449 bool _debugCheckHasValidScrollPosition () {
1450+ if (! mounted) {
1451+ return true ;
1452+ }
14501453 final ScrollController ? scrollController = widget.controller ?? PrimaryScrollController .of (context);
14511454 final bool tryPrimary = widget.controller == null ;
14521455 final String controllerForError = tryPrimary
Original file line number Diff line number Diff line change @@ -2444,4 +2444,42 @@ void main() {
24442444 }
24452445 expect (() => tester.pumpWidget (buildApp ()), throwsAssertionError);
24462446 });
2447+
2448+ testWidgets ('Skip the ScrollPosition check if the bar was unmounted' , (WidgetTester tester) async {
2449+ // Regression test for https://github.com/flutter/flutter/issues/103939
2450+ final ScrollController scrollController = ScrollController ();
2451+ Widget buildApp (bool buildBar) {
2452+ return Directionality (
2453+ textDirection: TextDirection .ltr,
2454+ child: MediaQuery (
2455+ data: MediaQueryData (
2456+ invertColors: buildBar, // Trigger a post frame check before unmount.
2457+ ),
2458+ child: PrimaryScrollController (
2459+ controller: scrollController,
2460+ child: LayoutBuilder (
2461+ builder: (BuildContext context, BoxConstraints constraints) {
2462+ Widget content = const SingleChildScrollView (
2463+ child: SizedBox (width: 4000.0 , height: 4000.0 ),
2464+ );
2465+ if (buildBar) {
2466+ content = RawScrollbar (
2467+ thumbVisibility: true ,
2468+ child: content,
2469+ );
2470+ }
2471+ return content;
2472+ },
2473+ ),
2474+ ),
2475+ ),
2476+ );
2477+ }
2478+
2479+ await tester.pumpWidget (buildApp (true ));
2480+
2481+ await tester.pumpWidget (buildApp (false ));
2482+
2483+ // Go without throw.
2484+ });
24472485}
You can’t perform that action at this time.
0 commit comments