fix a Scrollbar example crash (#127925)

Fix a scrollbar example crash.
https://api.flutter.dev/flutter/material/Scrollbar-class.html#material.Scrollbar.1
This commit is contained in:
xubaolin 2023-09-08 17:40:49 +08:00 committed by GitHub
parent bb8de2167a
commit f4707c2b3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -319,7 +319,6 @@ final Set<String> _knownMissingTests = <String>{
'examples/api/test/material/filled_button/filled_button.0_test.dart',
'examples/api/test/material/text_form_field/text_form_field.1_test.dart',
'examples/api/test/material/scrollbar/scrollbar.1_test.dart',
'examples/api/test/material/scrollbar/scrollbar.0_test.dart',
'examples/api/test/material/dropdown_menu/dropdown_menu.1_test.dart',
'examples/api/test/material/radio/radio.toggleable.0_test.dart',
'examples/api/test/material/radio/radio.0_test.dart',

View File

@ -29,6 +29,7 @@ class ScrollbarExample extends StatelessWidget {
Widget build(BuildContext context) {
return Scrollbar(
child: GridView.builder(
primary: true,
itemCount: 120,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
itemBuilder: (BuildContext context, int index) {

View File

@ -0,0 +1,21 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/material/scrollbar/scrollbar.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Scrollbar.0 works well on all platforms', (WidgetTester tester) async {
await tester.pumpWidget(
const example.ScrollbarExampleApp(),
);
final Finder buttonFinder = find.byType(Scrollbar);
await tester.drag(buttonFinder.last, const Offset(0, 100.0));
expect(tester.takeException(), isNull);
}, variant: TargetPlatformVariant.all());
}