पाठ 25 / 25

Revision and Interview Questions

Recall Dart concepts quickly for exams and interviews.

Cheat sheet

Platform: Dart VM with JIT (hot reload) for development; AOT to native, JavaScript and WebAssembly for release; dart CLI for create, run, test, analyze, format, fix, compile; pubspec.yaml and pub.dev with caret constraints. Basics: var, final (once, run time), const (compile time, canonicalised, deeply immutable), late; int, double, String interpolation, no implicit conversions; dynamic vs Object?. Null safety: sound, T?, promotion, ?., ??, ??=, ! sparingly, required. Collections: List, Set, Map (insertion-ordered by default), lazy Iterable methods, collection if/for, spread ..., cascades ... Functions: positional, optional [ ], named { } with required, arrow syntax, closures, typedefs, tear-offs. Errors: Exception vs Error, try/on/catch/finally, rethrow. Classes: initialising formals, named, const and factory constructors, initialiser lists, library-private _, extends, implicit interfaces with implements, mixins with with, abstract classes, enhanced enums, sealed/final/base/interface modifiers. Modern: records with structural equality, patterns, switch expressions with exhaustiveness, generics (reified), extension methods, extension types. Async: Futures, async/await, Future.wait or record .wait, Streams with async* and StreamController, cancel subscriptions, event and microtask queues, isolates with Isolate.run. Quality: analysis_options, lints, package:test, mocktail.

Common interview questions

Answer each with a short code example.

1. What is the difference between final and const? Why does const matter in Flutter?
2. Explain sound null safety and the ?, !, ?? and late features.
3. What are named, optional positional and required parameters?
4. Generative vs named vs factory vs const constructors: when do you use each?
5. extends vs implements vs with (mixins)?
6. What do sealed classes enable in Dart 3?
7. What are records and patterns? Give an example of destructuring JSON.
8. Future vs Stream; how do you run futures concurrently?
9. Explain the event loop, the microtask queue and the event queue.
10. What are isolates, and when should you use Isolate.run?
11. What are extension methods and extension types?
12. How do JIT and AOT compilation differ, and why does Flutter use both?

Relate answers to Flutter

Many Dart interviews are for Flutter roles. Tie each answer to a Flutter consequence: const widgets and rebuilds, isolates and smooth animations, sealed states and exhaustive UI rendering.

त्वरित जाँच: Which feature lets Dart check at compile time that a switch handles every subtype of a class?

  • Mixins
  • Extension methods
  • Factory constructors
  • Sealed classes with exhaustiveness checking
Answer

Sealed classes with exhaustiveness checking — Switching over a sealed type is checked for exhaustiveness.