Fix sample code crash, add test (#133812)

Fixes https://github.com/flutter/flutter/issues/133402

On web `1 << 32` crashes, 31 is the maximum.
This commit is contained in:
Kate Lovett
2023-08-31 17:56:06 -05:00
committed by GitHub
parent 7ade163885
commit 5b6d748cb4
3 changed files with 35 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
// 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/widgets/transitions/listenable_builder.3.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Tapping FAB adds to values', (WidgetTester tester) async {
await tester.pumpWidget(const example.ListenableBuilderExample());
final Finder listContent = find.byWidgetPredicate((Widget widget) => widget is example.ListBody);
expect(find.text('Current values:'), findsOneWidget);
expect(find.byIcon(Icons.add), findsOneWidget);
expect(
(tester.widget(listContent) as example.ListBody).listNotifier.values.isEmpty,
isTrue,
);
await tester.tap(find.byType(FloatingActionButton).first);
await tester.pumpAndSettle();
expect(
(tester.widget(listContent) as example.ListBody).listNotifier.values.isEmpty,
isFalse,
);
expect(
(tester.widget(listContent) as example.ListBody).listNotifier.values,
<int>[1464685455],
);
expect(find.text('1464685455'), findsOneWidget);
});
}