Unverified Commit 93211a48 authored by xubaolin's avatar xubaolin Committed by GitHub

[Scrollbar]Skip the ScrollPosition check if the bar was unmounted (#103948)

parent 80a51e4f
......@@ -1447,6 +1447,9 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
}
bool _debugCheckHasValidScrollPosition() {
if (!mounted) {
return true;
}
final ScrollController? scrollController = widget.controller ?? PrimaryScrollController.of(context);
final bool tryPrimary = widget.controller == null;
final String controllerForError = tryPrimary
......
......@@ -2444,4 +2444,42 @@ void main() {
}
expect(() => tester.pumpWidget(buildApp()), throwsAssertionError);
});
testWidgets('Skip the ScrollPosition check if the bar was unmounted', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/103939
final ScrollController scrollController = ScrollController();
Widget buildApp(bool buildBar) {
return Directionality(
textDirection: TextDirection.ltr,
child: MediaQuery(
data: MediaQueryData(
invertColors: buildBar, // Trigger a post frame check before unmount.
),
child: PrimaryScrollController(
controller: scrollController,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
Widget content = const SingleChildScrollView(
child: SizedBox(width: 4000.0, height: 4000.0),
);
if (buildBar) {
content = RawScrollbar(
thumbVisibility: true,
child: content,
);
}
return content;
},
),
),
),
);
}
await tester.pumpWidget(buildApp(true));
await tester.pumpWidget(buildApp(false));
// Go without throw.
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment