I have a variable of FutureOr<Duration?>
, I'm assuming that it can return either Future<Duration?>
or Duration?
, right?
how can I use it with the FutureBuilder
like a normal future method, that will wait for the Duration?
if it's future, if not, just use the Duration?
value directly.
when I try the following:
FutureBuilder<Duration?>(
future: durationFuture,
builder: (BuildContext context, snapshot) {
/* my widgets implementations */
},
),
this throws this:
The argument type 'FutureOr<Duration?>?' can't be assigned to the parameter type 'Future<Duration?>?'
how the FutureOr
type is working and how do I implement a FutureBuider based on it ?
CodePudding user response:
Try this:
FutureBuilder<Duration?>(
future: Future.value(durationFuture),
builder: (BuildContext context, snapshot) {
/* my widgets implementations */
},
)