Unverified Commit e8231cea authored by Loïc Sharma's avatar Loïc Sharma Committed by GitHub

Move examples to `ListenableBuilder` (#130671)

Updates examples to use the new `ListenableBuilder` if there's no animation. This is slightly more idiomatic.
parent 085d6c97
......@@ -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(
......
......@@ -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(
......
......@@ -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),
......@@ -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),
......
......@@ -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}');
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment