You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
você pode usar o Consumer para gerenciar o estado de um bloco de widget.
classHomePageextendsStatelessWidget {
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
appBar:AppBar(title:Text("Home"),
),
body:Center(
//reconhece a classe ChangeNotifier e reconstroi quando é chamado o notifyListeners()
child:Consumer<Counter>(
builder: (context, value) {
returnText('Counter ${value.counter}');
}
),
),
floatingActionButton:FloatingActionButton(
child:Icon(Icons.add),
onPressed: () {
//recuperando a classe diretamente e executando o método de incrementaçãoget<Counter>().increment();
},
),
);
}
}