Skip to content

Commit

Permalink
Move examples to ListenableBuilder (flutter#130671)
Browse files Browse the repository at this point in the history
Updates examples to use the new `ListenableBuilder` if there's no animation. This is slightly more idiomatic.
  • Loading branch information
loic-sharma authored and LouiseHsu committed Jul 31, 2023
1 parent 2fc71ca commit 4444109
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class _MyKeyExampleState extends State<MyKeyExample> {
child: Focus(
focusNode: _focusNode,
onKey: _handleKeyEvent,
child: AnimatedBuilder(
animation: _focusNode,
child: ListenableBuilder(
listenable: _focusNode,
builder: (BuildContext context, Widget? child) {
if (!_focusNode.hasFocus) {
return GestureDetector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class _MyPhysicalKeyExampleState extends State<MyPhysicalKeyExample> {
child: Focus(
focusNode: _focusNode,
onKey: _handleKeyEvent,
child: AnimatedBuilder(
animation: _focusNode,
child: ListenableBuilder(
listenable: _focusNode,
builder: (BuildContext context, Widget? child) {
if (!_focusNode.hasFocus) {
return GestureDetector(
Expand Down
8 changes: 4 additions & 4 deletions examples/api/lib/widgets/actions/actions.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class _SaveButtonState extends State<SaveButton> {

@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),
Expand Down Expand Up @@ -146,8 +146,8 @@ class _ActionsExampleState extends State<ActionsExample> {
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),
Expand Down
4 changes: 2 additions & 2 deletions examples/api/lib/widgets/shortcuts/shortcuts.1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class _ShortcutsExampleState extends State<ShortcutsExample> {
children: <Widget>[
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}');
},
Expand Down

0 comments on commit 4444109

Please sign in to comment.