0
Hello!
I’m trying to finalize an app, but I stopped in a problem.
I have a screen with a Scaffold and a action in appBar with widget that returns the date.
I would like to know how to update a text with the date inside the body. I know it can be updated. Yeah, I can print it and see it changes the value but I can’t change the text.
data file.Dart
class Data extends StatefulWidget {
  @override
  _DataState createState() => _DataState();
}
class _DataState extends State<Data> {
  StoreChamada testeData = StoreChamada();
  DateTime selectDate = DateTime.now();
  Future<Null> _selectdate(BuildContext context) async {
    final DateTime picked = await showDatePicker(
        context: context,
        initialDate: selectDate,
        firstDate: DateTime(2000, 1),
        lastDate: DateTime(2050));
    testeData.setData(DateFormat('dd-MM').format(picked));
    if (picked != null && picked != selectDate)
      setState(() {
        selectDate = picked;
      });
  }
  @override
  Widget build(BuildContext context) {
    var data = DateFormat('dd-MM').format(selectDate);
    return Row(children: <Widget>[
      Text(data + '  '),
      IconButton(
        icon: Icon(IconData(59670, fontFamily: 'MaterialIcons')),
        onPressed: () {
          setState(() {
            _selectdate(context);
          });
        },
      )
    ]);
  }
}
function I call to update the value of the variable sdata with the date I use on the body.
void setData(value) => sdata = value;
list screen that has the text.
 body: Container(
          child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text(sdata == null
              ? '${DateFormat('dd-MM').format(DateTime.now())}'
              : sdata),
I tried several things, I thought about using a setstate(){} on the body but I don’t even know if that would be possible. Anyway, if anyone can help.
That’s the screen I’d like to change. I have a widget with text and date that are updated as soon as I change the date, but I can’t update the yellow part which is where the data I update is located depending on the date. The date value is changed but the screen does not update, only when I hotreload.

It was not clear what the problem is, you need to update which scaffold? What is the structure of widgets? If you are instantiating your widget, you cannot use a callback?
– Leo Letto
The one with the text sdata, the last snippet of the code.
– Fernando Foster
Ok, how are your widgets structured? You have a widget with a scaffold, and within this you have your widget to select the date?
– Leo Letto
Yes. I have a screen with a scaffold -> appBar(action-> widget that changes the date, the first snippet of code.
– Fernando Foster