mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Use ScrollbarTheme instead Theme for Scrollbar (#113237)
This commit is contained in:
parent
3d94b8fd1d
commit
abfaec6811
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user