extends

State

Foo

String

buttonLabel

'Click Me'

@override

Widget

build

BuildContext

context

return

ElevatedButton

onPressed:

()

async

// Illegal state modification that should be wrapped in setState.

buttonLabel

await

Navigator

pushNamed

context

'/bar'

);

},

child:

Text

buttonLabel

),

);

Code after migration:

class

FooState

extends

State

Foo