Unverified Commit abfaec68 authored by Oleg's avatar Oleg Committed by GitHub

Use ScrollbarTheme instead Theme for Scrollbar (#113237)

parent 3d94b8fd
......@@ -399,7 +399,7 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> {
void didChangeDependencies() {
final ThemeData theme = Theme.of(context);
_colorScheme = theme.colorScheme;
_scrollbarTheme = theme.scrollbarTheme;
_scrollbarTheme = ScrollbarTheme.of(context);
switch (theme.platform) {
case TargetPlatform.android:
_useAndroidScrollbar = true;
......
......@@ -206,6 +206,50 @@ void main() {
}),
);
testWidgets(
'Scrollbar uses values from ScrollbarTheme if exists instead of values from Theme',
(WidgetTester tester) async {
final ScrollbarThemeData scrollbarTheme = _scrollbarTheme();
final ScrollController scrollController = ScrollController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(
scrollbarTheme: scrollbarTheme,
),
home: ScrollConfiguration(
behavior: const NoScrollbarBehavior(),
child: ScrollbarTheme(
data: _scrollbarTheme().copyWith(
thumbColor: MaterialStateProperty.all(const Color(0xFF000000)),
),
child: Scrollbar(
thumbVisibility: true,
controller: scrollController,
child: SingleChildScrollView(
controller: scrollController,
child: const SizedBox(width: 4000.0, height: 4000.0),
),
),
),
),
),
);
await tester.pumpAndSettle();
// Idle scrollbar behavior
expect(
find.byType(Scrollbar),
paints
..rrect(
rrect: RRect.fromRectAndRadius(
const Rect.fromLTRB(785.0, 10.0, 795.0, 97.0),
const Radius.circular(6.0),
),
color: const Color(0xFF000000),
),
);
},
);
testWidgets('ScrollbarTheme can disable gestures', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController();
await tester.pumpWidget(MaterialApp(
......
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