Added new constructor RefreshIndicator.noSpinner() (#152075)

This PR adds a new constructor to the RefreshIndicator's class, which is `noSpinner`.
The purpose of this new constructor is to create a RefreshIndicator that doesn't show a spinner when the user arms it by pulling.

The work is based on a partial that is here: https://github.com/flutter/flutter/pull/133507

I addressed the following issues reported in the PR above:
- in the example for `noSpinner`, arming the RefreshIndicator now shows a CircularProgressIndicator, instead of just printing text to the console;
- added a test for the new example;
- added a doc comment on the new constructor;

Fixes https://github.com/flutter/flutter/issues/132775
This commit is contained in:
Pavlo Kochylo
2024-08-23 22:37:24 +02:00
committed by GitHub
parent 5e194383af
commit a4b0d973fb
4 changed files with 360 additions and 91 deletions

View File

@@ -0,0 +1,26 @@
// 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/refresh_indicator/refresh_indicator.2.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Pulling from scroll view triggers a refresh indicator which shows a CircularProgressIndicator', (WidgetTester tester) async {
await tester.pumpWidget(
const example.RefreshIndicatorExampleApp(),
);
// Pull the first item.
await tester.fling(find.text('Pull down here').first, const Offset(0.0, 300.0), 1000.0);
await tester.pump();
await tester.pump(const Duration(seconds: 1));
await tester.pump(const Duration(seconds: 1));
expect(find.byType(RefreshProgressIndicator), findsNothing);
expect(find.bySemanticsLabel('Circular progress indicator'), findsOneWidget);
await tester.pumpAndSettle(); // Advance pending time.
});
}