Home > Software engineering >  Using Flutter and Dart, why String variable's value is changing over screen transfer?
Using Flutter and Dart, why String variable's value is changing over screen transfer?

Time:08-24

At my first screen this is the code and result:

appController.mydate=DateTime.parse(info.timestamp).toLocal().toString().substring(0, DateTime.parse(info.timestamp).toLocal().toString().length - 7).replaceAll("T", " ");
print(appController.mydate);
I/flutter (27269): 2022-08-01 13:08
I/flutter (27269): 2022-08-01 12:54
I/flutter (27269): 2022-08-01 11:46
I/flutter (27269): 2022-07-13 12:42

At my second screen this is the code and result:

print(widget.appController.mydate);
I/flutter (27269): 2022-07-13 12:42

It stores only the last value on transfer, i want all the values(dates).

CodePudding user response:

It is printing last date cause you display all date time in screen 1 ( As they printing in all at new line)

And you are passing last value only. So, I guess you are using for loop or something for printing in first screen.

  • Related