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> { ...@@ -74,8 +74,8 @@ class _MyKeyExampleState extends State<MyKeyExample> {
child: Focus( child: Focus(
focusNode: _focusNode, focusNode: _focusNode,
onKey: _handleKeyEvent, onKey: _handleKeyEvent,
child: AnimatedBuilder( child: ListenableBuilder(
animation: _focusNode, listenable: _focusNode,
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
if (!_focusNode.hasFocus) { if (!_focusNode.hasFocus) {
return GestureDetector( return GestureDetector(
......
...@@ -74,8 +74,8 @@ class _MyPhysicalKeyExampleState extends State<MyPhysicalKeyExample> { ...@@ -74,8 +74,8 @@ class _MyPhysicalKeyExampleState extends State<MyPhysicalKeyExample> {
child: Focus( child: Focus(
focusNode: _focusNode, focusNode: _focusNode,
onKey: _handleKeyEvent, onKey: _handleKeyEvent,
child: AnimatedBuilder( child: ListenableBuilder(
animation: _focusNode, listenable: _focusNode,
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
if (!_focusNode.hasFocus) { if (!_focusNode.hasFocus) {
return GestureDetector( return GestureDetector(
......
...@@ -91,8 +91,8 @@ class _SaveButtonState extends State<SaveButton> { ...@@ -91,8 +91,8 @@ class _SaveButtonState extends State<SaveButton> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AnimatedBuilder( return ListenableBuilder(
animation: widget.valueNotifier, listenable: widget.valueNotifier,
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return TextButton.icon( return TextButton.icon(
icon: const Icon(Icons.save), icon: const Icon(Icons.save),
...@@ -146,8 +146,8 @@ class _ActionsExampleState extends State<ActionsExample> { ...@@ -146,8 +146,8 @@ class _ActionsExampleState extends State<ActionsExample> {
Actions.invoke(context, ModifyIntent(++count)); Actions.invoke(context, ModifyIntent(++count));
}, },
), ),
AnimatedBuilder( ListenableBuilder(
animation: model.data, listenable: model.data,
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return Padding( return Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
......
...@@ -100,8 +100,8 @@ class _ShortcutsExampleState extends State<ShortcutsExample> { ...@@ -100,8 +100,8 @@ class _ShortcutsExampleState extends State<ShortcutsExample> {
children: <Widget>[ children: <Widget>[
const Text('Add to the counter by pressing the up arrow key'), const Text('Add to the counter by pressing the up arrow key'),
const Text('Subtract from the counter by pressing the down arrow key'), const Text('Subtract from the counter by pressing the down arrow key'),
AnimatedBuilder( ListenableBuilder(
animation: model, listenable: model,
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return Text('count: ${model.count}'); 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