Skip to content

Commit e8231ce

Browse files
authored
Move examples to ListenableBuilder (#130671)
Updates examples to use the new `ListenableBuilder` if there's no animation. This is slightly more idiomatic.
1 parent 085d6c9 commit e8231ce

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

examples/api/lib/services/keyboard_key/logical_keyboard_key.0.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class _MyKeyExampleState extends State<MyKeyExample> {
7474
child: Focus(
7575
focusNode: _focusNode,
7676
onKey: _handleKeyEvent,
77-
child: AnimatedBuilder(
78-
animation: _focusNode,
77+
child: ListenableBuilder(
78+
listenable: _focusNode,
7979
builder: (BuildContext context, Widget? child) {
8080
if (!_focusNode.hasFocus) {
8181
return GestureDetector(

examples/api/lib/services/keyboard_key/physical_keyboard_key.0.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class _MyPhysicalKeyExampleState extends State<MyPhysicalKeyExample> {
7474
child: Focus(
7575
focusNode: _focusNode,
7676
onKey: _handleKeyEvent,
77-
child: AnimatedBuilder(
78-
animation: _focusNode,
77+
child: ListenableBuilder(
78+
listenable: _focusNode,
7979
builder: (BuildContext context, Widget? child) {
8080
if (!_focusNode.hasFocus) {
8181
return GestureDetector(

examples/api/lib/widgets/actions/actions.0.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ class _SaveButtonState extends State<SaveButton> {
9191

9292
@override
9393
Widget build(BuildContext context) {
94-
return AnimatedBuilder(
95-
animation: widget.valueNotifier,
94+
return ListenableBuilder(
95+
listenable: widget.valueNotifier,
9696
builder: (BuildContext context, Widget? child) {
9797
return TextButton.icon(
9898
icon: const Icon(Icons.save),
@@ -146,8 +146,8 @@ class _ActionsExampleState extends State<ActionsExample> {
146146
Actions.invoke(context, ModifyIntent(++count));
147147
},
148148
),
149-
AnimatedBuilder(
150-
animation: model.data,
149+
ListenableBuilder(
150+
listenable: model.data,
151151
builder: (BuildContext context, Widget? child) {
152152
return Padding(
153153
padding: const EdgeInsets.all(8.0),

examples/api/lib/widgets/shortcuts/shortcuts.1.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class _ShortcutsExampleState extends State<ShortcutsExample> {
100100
children: <Widget>[
101101
const Text('Add to the counter by pressing the up arrow key'),
102102
const Text('Subtract from the counter by pressing the down arrow key'),
103-
AnimatedBuilder(
104-
animation: model,
103+
ListenableBuilder(
104+
listenable: model,
105105
builder: (BuildContext context, Widget? child) {
106106
return Text('count: ${model.count}');
107107
},

0 commit comments

Comments
 (0)