May
May

Reputation: 157

Flutter: Await future from the past

If have a variable:

Future<CarList?> carList;

I set this variable every couple of seconds via a backend call. In UI, I use FutureBuilder to show carList, which works OK. But outside UI, how can I get the value of carList? Can I just use await carList, will this always complete?

Upvotes: 0

Views: 37

Answers (1)

Bhushan Jadhav
Bhushan Jadhav

Reputation: 1

Declare CarList cartList ; variable globally and assign value it in FutureBuilder, than you can easily access it anywhere in your dart file.

Upvotes: 0

Related Questions