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

@@ -39,7 +39,7 @@ class _ListenableBuilderExampleState extends State<ListenableBuilderExample> {
appBar: AppBar(title: const Text('ListenableBuilder Example')),
body: ListBody(listNotifier: _listNotifier),
floatingActionButton: FloatingActionButton(
onPressed: () => _listNotifier.add(_random.nextInt(1 << 32)), // 1 << 32 is the maximum supported value
onPressed: () => _listNotifier.add(_random.nextInt(1 << 31)), // 1 << 31 is the maximum supported value
child: const Icon(Icons.add),
),
),