From 4444109be9a5b641e32c56b74884a936b24c1587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sharma?= <737941+loic-sharma@users.noreply.github.com> Date: Mon, 17 Jul 2023 14:06:15 -0700 Subject: [PATCH] Move examples to `ListenableBuilder` (#130671) Updates examples to use the new `ListenableBuilder` if there's no animation. This is slightly more idiomatic. --- .../lib/services/keyboard_key/logical_keyboard_key.0.dart | 4 ++-- .../services/keyboard_key/physical_keyboard_key.0.dart | 4 ++-- examples/api/lib/widgets/actions/actions.0.dart | 8 ++++---- examples/api/lib/widgets/shortcuts/shortcuts.1.dart | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/api/lib/services/keyboard_key/logical_keyboard_key.0.dart b/examples/api/lib/services/keyboard_key/logical_keyboard_key.0.dart index 3be60f244dee3..77b09d3038e1d 100644 --- a/examples/api/lib/services/keyboard_key/logical_keyboard_key.0.dart +++ b/examples/api/lib/services/keyboard_key/logical_keyboard_key.0.dart @@ -74,8 +74,8 @@ class _MyKeyExampleState extends State { child: Focus( focusNode: _focusNode, onKey: _handleKeyEvent, - child: AnimatedBuilder( - animation: _focusNode, + child: ListenableBuilder( + listenable: _focusNode, builder: (BuildContext context, Widget? child) { if (!_focusNode.hasFocus) { return GestureDetector( diff --git a/examples/api/lib/services/keyboard_key/physical_keyboard_key.0.dart b/examples/api/lib/services/keyboard_key/physical_keyboard_key.0.dart index c5eaf1cd25165..6b569409bbbad 100644 --- a/examples/api/lib/services/keyboard_key/physical_keyboard_key.0.dart +++ b/examples/api/lib/services/keyboard_key/physical_keyboard_key.0.dart @@ -74,8 +74,8 @@ class _MyPhysicalKeyExampleState extends State { child: Focus( focusNode: _focusNode, onKey: _handleKeyEvent, - child: AnimatedBuilder( - animation: _focusNode, + child: ListenableBuilder( + listenable: _focusNode, builder: (BuildContext context, Widget? child) { if (!_focusNode.hasFocus) { return GestureDetector( diff --git a/examples/api/lib/widgets/actions/actions.0.dart b/examples/api/lib/widgets/actions/actions.0.dart index e8f3366e22671..9752b07cfa6b3 100644 --- a/examples/api/lib/widgets/actions/actions.0.dart +++ b/examples/api/lib/widgets/actions/actions.0.dart @@ -91,8 +91,8 @@ class _SaveButtonState extends State { @override Widget build(BuildContext context) { - return AnimatedBuilder( - animation: widget.valueNotifier, + return ListenableBuilder( + listenable: widget.valueNotifier, builder: (BuildContext context, Widget? child) { return TextButton.icon( icon: const Icon(Icons.save), @@ -146,8 +146,8 @@ class _ActionsExampleState extends State { Actions.invoke(context, ModifyIntent(++count)); }, ), - AnimatedBuilder( - animation: model.data, + ListenableBuilder( + listenable: model.data, builder: (BuildContext context, Widget? child) { return Padding( padding: const EdgeInsets.all(8.0), diff --git a/examples/api/lib/widgets/shortcuts/shortcuts.1.dart b/examples/api/lib/widgets/shortcuts/shortcuts.1.dart index 6f1281d0fc592..8d59f00601fcd 100644 --- a/examples/api/lib/widgets/shortcuts/shortcuts.1.dart +++ b/examples/api/lib/widgets/shortcuts/shortcuts.1.dart @@ -100,8 +100,8 @@ class _ShortcutsExampleState extends State { children: [ const Text('Add to the counter by pressing the up arrow key'), const Text('Subtract from the counter by pressing the down arrow key'), - AnimatedBuilder( - animation: model, + ListenableBuilder( + listenable: model, builder: (BuildContext context, Widget? child) { return Text('count: ${model.count}'); },