Dart Questions Flutter Interview Questions
5 questions
What is null safety in Dart?
Sound null safety means the compiler distinguishes nullable (`String?`) from non-nullable (`String`) types and guarantees, at compile time, that a non-nullable variable can never hold null.
What is the difference between Future and Stream in Dart?
A Future represents a single asynchronous value that completes once; a Stream represents a sequence of asynchronous values delivered over time, and can emit zero, one, or many events.
How does async/await work in Dart?
`async` marks a function as returning a Future and lets you use `await` inside it; `await` pauses execution of that function (without blocking the thread) until the awaited Future completes.
What are extension methods in Dart?
Extension methods let you add new functionality to an existing type — including types you don't own, like String or int — without modifying its source or subclassing it.
What are mixins in Dart and when would you use one?
A mixin lets a class reuse a chunk of behavior from multiple sources without using multiple inheritance — you declare it with `mixin` and apply it with `with`.