Home > database >  How to retrieve a value from Widget
How to retrieve a value from Widget

Time:05-16

I'm very new to coding so i don't know too much, i'm sorry. I'm trying to get the value passed from screen 1 to screen 2, but the value is inside the widget from stateful. like that:

class Escrita extends StatefulWidget {


  List<Diario> _diarioupdate = <Diario>[];
  Escrita({Diario? teste});



  @override
  State<Escrita> createState() => _EscritaState();
}

and i want to retrieve the value teste that is passed from screen 1, how can i do that?

CodePudding user response:

I believe you are asking how to access the _diarioUpdate inside your stateful widget. This can be accomplished removing the underscore(_) from the _diarioupdate so that it won't be private member and then calling it inside the statefulwidget as widget.diarioupdate.

CodePudding user response:

in _EscritaState you can can call widget._diarioupdate

CodePudding user response:

i found the answer. Thank you so much for helping. I solved like this:

Escrita({Diario? teste}){
this.teste};


  • Related