[Scrollbar]Skip the ScrollPosition check if the bar was unmounted (#103948)
This commit is contained in:
parent
80a51e4f97
commit
93211a48d7
@ -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.
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user