Object Orientation - Flutter

Asked

Viewed 101 times

2

I have an application in flutter that has a form and that the data is sent to a class, however, I have a specific screen that needs to recover a class data in which I sent, but when I recover the variable returns null.

Sending of the Data:

Especialidade VarEspecialidade = new Especialidade();
VarEspecialidade.VariavelEspecialidade = DadosLista[index];

Class receiving the data:

class Especialidade {

  String VariavelEspecialidade;
  Especialidade({this.VariavelEspecialidade});

}

Screen I call the dice:

class _Layout_Conclusao extends State<Layout_Conclusao>{

  Especialidade VarEspecialidade = new Especialidade();
  String Dados;

  @override
  void initState(){
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Conclusão'),
        centerTitle: true,
        elevation: 0,
      ),
      body: Text(VarEspecialidade.VariavelEspecialidade.toString())
    );
  }

}

1 answer

1


As your example is half raw and there is no way to know when you fill in the data, do so in the place where you feed the variable:

setState((){
  VarEspecialidade.VariavelEspecialidade = DadosLista[index];
});

I advise you to study about State-management or state management in Flutter.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.