Bidev

Dart Questions Flutter Interview Questions

10 questions

Advertisement
BeginnerDart 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.

IntermediateDart Questions

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.

BeginnerDart Questions

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.

IntermediateDart Questions

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.

IntermediateDart Questions

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`.

IntermediateDart Questions

What are Records in Dart and when would you use one?

A Record is a built-in, anonymous, immutable data structure that groups multiple values together — useful for returning multiple values from a function without declaring a dedicated class.

AdvancedDart Questions

What are sealed classes in Dart and how do they enable exhaustive pattern matching?

A sealed class restricts which classes can extend/implement it to only those defined in the same library, letting the compiler verify a switch statement handles every possible subtype — catching missing cases at compile time instead of runtime.

BeginnerDart Questions

What does the late keyword do in Dart, and what's a common mistake with it?

late tells the compiler a non-nullable variable will definitely be assigned before use, even though it can't verify that at compile time — deferring the null-safety check to runtime, where accessing it before assignment throws a LateInitializationError.

IntermediateDart Questions

What is a factory constructor in Dart and when would you use one?

A factory constructor can return an existing instance instead of always creating a new one, or return a subtype — useful for caching/singleton patterns and for fromJson constructors that might return different subclasses based on the data.

IntermediateDart Questions

How do generics work in Dart and why are they useful?

Generics let a class or function be written once and work with any type, while still giving compile-time type safety — List<String> and List<int> are both Lists, but the compiler prevents mixing types into either.

Advertisement