Fix RawScrollbar examples and desktop test (#158237)
## Description Fix the formatting of some `RawScrollbar` examples. Fix and rename one test file (name without `_test` suffix).
This commit is contained in:
parent
66e8f53ba0
commit
22a7afd99a
@ -312,5 +312,4 @@ final Set<String> _knownMissingTests = <String>{
|
|||||||
'examples/api/test/material/color_scheme/dynamic_content_color.0_test.dart',
|
'examples/api/test/material/color_scheme/dynamic_content_color.0_test.dart',
|
||||||
'examples/api/test/widgets/image/image.frame_builder.0_test.dart',
|
'examples/api/test/widgets/image/image.frame_builder.0_test.dart',
|
||||||
'examples/api/test/widgets/image/image.loading_builder.0_test.dart',
|
'examples/api/test/widgets/image/image.loading_builder.0_test.dart',
|
||||||
'examples/api/test/widgets/scrollbar/raw_scrollbar.desktop.0_test.dart',
|
|
||||||
};
|
};
|
||||||
|
@ -32,11 +32,11 @@ class RawScrollbarExample extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RawScrollbarExampleState extends State<RawScrollbarExample> {
|
class _RawScrollbarExampleState extends State<RawScrollbarExample> {
|
||||||
final ScrollController _firstController = ScrollController();
|
final ScrollController _controller = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_firstController.dispose();
|
_controller.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,47 +46,52 @@ class _RawScrollbarExampleState extends State<RawScrollbarExample> {
|
|||||||
return Row(
|
return Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: constraints.maxWidth / 2,
|
width: constraints.maxWidth / 2,
|
||||||
// When using the PrimaryScrollController and a Scrollbar
|
// When using the PrimaryScrollController and a Scrollbar
|
||||||
// together, only one ScrollPosition can be attached to the
|
// together, only one ScrollPosition can be attached to the
|
||||||
// PrimaryScrollController at a time. Providing a
|
// PrimaryScrollController at a time. Providing a
|
||||||
// unique scroll controller to this scroll view prevents it
|
// unique scroll controller to this scroll view prevents it
|
||||||
// from attaching to the PrimaryScrollController.
|
// from attaching to the PrimaryScrollController.
|
||||||
child: Scrollbar(
|
child: Scrollbar(
|
||||||
thumbVisibility: true,
|
thumbVisibility: true,
|
||||||
controller: _firstController,
|
controller: _controller,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
controller: _firstController,
|
controller: _controller,
|
||||||
itemCount: 100,
|
itemCount: 100,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Text('Scrollable 1 : Index $index'),
|
child: Text('Scrollable 1 : Index $index'),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: constraints.maxWidth / 2,
|
width: constraints.maxWidth / 2,
|
||||||
// This vertical scroll view has primary set to true, so it is
|
// This vertical scroll view has primary set to true, so it is
|
||||||
// using the PrimaryScrollController. On mobile platforms, the
|
// using the PrimaryScrollController. On mobile platforms, the
|
||||||
// PrimaryScrollController automatically attaches to vertical
|
// PrimaryScrollController automatically attaches to vertical
|
||||||
// ScrollViews, unlike on Desktop platforms, where the primary
|
// ScrollViews, unlike on Desktop platforms, where the primary
|
||||||
// parameter is required.
|
// parameter is required.
|
||||||
child: Scrollbar(
|
child: Scrollbar(
|
||||||
thumbVisibility: true,
|
thumbVisibility: true,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
primary: true,
|
primary: true,
|
||||||
itemCount: 100,
|
itemCount: 100,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return Container(
|
return Container(
|
||||||
height: 50,
|
height: 50,
|
||||||
color: index.isEven ? Colors.amberAccent : Colors.blueAccent,
|
color: index.isEven ? Colors.amberAccent : Colors.blueAccent,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Text('Scrollable 2 : Index $index'),
|
child: Text('Scrollable 2 : Index $index'),
|
||||||
));
|
),
|
||||||
}),
|
);
|
||||||
)),
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -30,21 +30,21 @@ class RawScrollbarExample extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RawScrollbarExampleState extends State<RawScrollbarExample> {
|
class _RawScrollbarExampleState extends State<RawScrollbarExample> {
|
||||||
final ScrollController _controllerOne = ScrollController();
|
final ScrollController _controller = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_controllerOne.dispose();
|
_controller.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return RawScrollbar(
|
return RawScrollbar(
|
||||||
controller: _controllerOne,
|
controller: _controller,
|
||||||
thumbVisibility: true,
|
thumbVisibility: true,
|
||||||
child: GridView.builder(
|
child: GridView.builder(
|
||||||
controller: _controllerOne,
|
controller: _controller,
|
||||||
itemCount: 120,
|
itemCount: 120,
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
@ -32,11 +32,11 @@ class DesktopExample extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DesktopExampleState extends State<DesktopExample> {
|
class _DesktopExampleState extends State<DesktopExample> {
|
||||||
final ScrollController controller = ScrollController();
|
final ScrollController _controller = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
controller.dispose();
|
_controller.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,54 +46,56 @@ class _DesktopExampleState extends State<DesktopExample> {
|
|||||||
return Row(
|
return Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: constraints.maxWidth / 2,
|
width: constraints.maxWidth / 2,
|
||||||
// When running this sample on desktop, two scrollbars will be
|
// When running this sample on desktop, two scrollbars will be
|
||||||
// visible here. One is the default scrollbar and the other is the
|
// visible here. One is the default scrollbar and the other is the
|
||||||
// Scrollbar widget with custom thickness.
|
// Scrollbar widget with custom thickness.
|
||||||
child: Scrollbar(
|
child: Scrollbar(
|
||||||
thickness: 20.0,
|
thickness: 20.0,
|
||||||
thumbVisibility: true,
|
thumbVisibility: true,
|
||||||
controller: controller,
|
controller: _controller,
|
||||||
|
child: ListView.builder(
|
||||||
|
controller: _controller,
|
||||||
|
itemCount: 100,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 50,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text('Scrollable 1 : Index $index'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: constraints.maxWidth / 2,
|
||||||
|
// When running this sample on desktop, one scrollbar will be
|
||||||
|
// visible here. The default scrollbar is hidden by setting the
|
||||||
|
// ScrollConfiguration's scrollbars to false. The Scrollbar widget
|
||||||
|
// with custom thickness is visible.
|
||||||
|
child: Scrollbar(
|
||||||
|
thickness: 20.0,
|
||||||
|
thumbVisibility: true,
|
||||||
|
child: ScrollConfiguration(
|
||||||
|
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
controller: controller,
|
primary: true,
|
||||||
itemCount: 100,
|
itemCount: 100,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 50,
|
height: 50,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Text('Scrollable 1 : Index $index'),
|
child: Text('Scrollable 2 : Index $index'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)),
|
),
|
||||||
SizedBox(
|
),
|
||||||
width: constraints.maxWidth / 2,
|
),
|
||||||
// When running this sample on desktop, one scrollbar will be
|
|
||||||
// visible here. The default scrollbar is hidden by setting the
|
|
||||||
// ScrollConfiguration's scrollbars to false. The Scrollbar widget
|
|
||||||
// with custom thickness is visible.
|
|
||||||
child: Scrollbar(
|
|
||||||
thickness: 20.0,
|
|
||||||
thumbVisibility: true,
|
|
||||||
child: ScrollConfiguration(
|
|
||||||
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
|
|
||||||
child: ListView.builder(
|
|
||||||
primary: true,
|
|
||||||
itemCount: 100,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
return SizedBox(
|
|
||||||
height: 50,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text('Scrollable 2 : Index $index'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,6 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Can hide default scrollbar on desktop', (WidgetTester tester) async {
|
testWidgets('Can hide default scrollbar on desktop', (WidgetTester tester) async {
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const example.ScrollbarApp(),
|
const example.ScrollbarApp(),
|
||||||
);
|
);
|
||||||
@ -16,5 +15,5 @@ void main() {
|
|||||||
// Two from left list view where scroll configuration is not set.
|
// Two from left list view where scroll configuration is not set.
|
||||||
// One from right list view where scroll configuration is set.
|
// One from right list view where scroll configuration is set.
|
||||||
expect(find.byType(Scrollbar), findsNWidgets(3));
|
expect(find.byType(Scrollbar), findsNWidgets(3));
|
||||||
});
|
}, variant: TargetPlatformVariant.desktop());
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user