Move examples to ListenableBuilder
(#130671)
Updates examples to use the new `ListenableBuilder` if there's no animation. This is slightly more idiomatic.
This commit is contained in:
parent
085d6c9700
commit
e8231cea4c
@ -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}');
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user