Answer Similarity: Future and Stream both work asynchronously.
Both have some potential value.
Differences: A Stream is a combination of Futures.
Future has only one response but Stream could have any number of Response.
Q24: What is Future in Flutter/Dart? GET START Senior Top 68 Flutter Interview Questions Flutter 68 Answer A Future is used to represent a potential value, or error, that will be available
at some time in the future. Receivers of a Future can register callbacks that handl
e the value or error once it is available. For example:
Future future = getFuture();
future.then((value) => handleValue(value))
.catchError((error) => handleError(error));
If a future doesn’t produce a usable value, then the future’s type is Future .
A future represents the result of an asynchronous operation, and can have two state
s:
Uncompleted When you call an asynchronous function, it returns an uncompleted f
uture. That future is waiting for the function’s asynchronous operation to finish o
r to throw an error.
Completed If the asynchronous operation succeeds, the future completes with a
value. Otherwise it completes with an error.
Q25: What is a difference between these operators "?? and ?." GET START Senior Top 68 Flutter Interview Questions Flutter 68 Answer ?? It is a null-aware operator which returns the expression on its left unless that ex
pression’s value is null, in which case it evaluates and returns the expression on
its right:
print(1 ?? 3); // <-- Prints 1. print(null ?? 12); // <-- Prints 12. ?. It is a conditional property access which is used to guard access to a property or
method of an object that might be null, put a question mark (?) before the dot (.):
You can chain multiple uses of ?. together in a single expression: