Commit 93211a4 1 parent 80a51e4 commit 93211a4 Copy full SHA for 93211a4
File tree 2 files changed +41
-0
lines changed
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
1447
1447
}
1448
1448
1449
1449
bool _debugCheckHasValidScrollPosition () {
1450
+ if (! mounted) {
1451
+ return true ;
1452
+ }
1450
1453
final ScrollController ? scrollController = widget.controller ?? PrimaryScrollController .of (context);
1451
1454
final bool tryPrimary = widget.controller == null ;
1452
1455
final String controllerForError = tryPrimary
Original file line number Diff line number Diff line change @@ -2444,4 +2444,42 @@ void main() {
2444
2444
}
2445
2445
expect (() => tester.pumpWidget (buildApp ()), throwsAssertionError);
2446
2446
});
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
+ });
2447
2485
}
You can’t perform that action at this time.
0 commit comments