Flutter
294 bites tagged Flutter — interview questions with model answers, and 60-second explainers.
How do you test Flutter platform channels and mock native responses?
Tests MethodChannel mocking in widget tests. Strong answers intercept calls via TestDefaultBinaryMessengerBinding, encode replies with StandardMessageCodec, pump the widget, and assert UI state.
Set up an integration test for a multi-screen login flow
This tests your grasp of integration_test's device runtime versus headless widget tests. A strong answer covers the integration_test directory, ensureInitialized, driving a login flow end-to-end on device.
Compare sqflite and Drift: trade-offs and when to choose Drift
This tests Flutter persistence trade-offs. Contrast sqflite's raw maps and raw SQL with Drift's typed code, streams, and migrations; choose Drift for complex schemas or web targets. Red flag: calling Drift bloat or claiming raw sqflite is always faster.
Fix UI jank from file reads and SQLite inserts using Isolates
This tests whether you know heavy synchronous work blocks Dart's UI event loop past the 16ms frame budget. A strong answer offloads parsing and SQLite inserts to a worker isolate via compute, returning results.
When to use shared_preferences and its primary limitations?
This tests whether you know appropriate local persistence tiers. A strong answer names simple primitives like flags or tokens, notes async disk writes, and warns against large blobs, relational data, or secrets.
Describe the BLoC pattern: Events, States, and widget connection
Tests UI-business separation. Strong answers cast Events as user intents, States as immutable snapshots, and BLoC as a pure reducer. Widgets listen via BlocBuilder and dispatch via context.read. Red flag: mutating state directly or using setState inside BLoC.
Describe a strategy to decouple TextEditingController from global state
It tests your understanding of ephemeral versus app state in Flutter. Keep the controller local, debounce input so finalized values reach BLoC or Riverpod, and let the field own its state while editing.
Which widget overlays and centers a loading indicator on an image?
Stack with Image first (bottom), then Center-wrapped indicator; constrain Stack to image. Stack overlays and centering non-positioned children. Column/Row or manual Positioned offsets instead of Stack/Center alignment.
How would you implement debounce for a search input using Streams?
This tests Stream transformation and event throttling. A strong answer outlines a resetting timer that only emits after 300ms of silence, referencing debounceTime or DebounceStreamTransformer. Red flag: manual Timer juggling without Stream composition.
What is Flutter tree shaking and how does it reduce app size?
Tests Dart AOT dead code elimination. Covers compile-time dead code removal, smaller binaries, faster startup, and practices like avoiding dart:mirrors and using const constructors. Red flag: confusing it with minification or runtime stripping.
When would you implement a CustomPainter and how does shouldRepaint work?
Use CustomPainter for charts; check fields in shouldRepaint to skip frames; pass Listenable to bypass build layout. Knowledge of Flutter render pipeline repaint optimization.
What is a Dart Isolate and how does it differ from threads?
Tests Dart's shared-nothing concurrency model. Define an isolate as an independent heap plus event loop, contrast it with shared-memory threads, and explain UI isolate communication via async message ports.
Explain 'constraints go down, sizes go up, parent sets position.'
Tests Flutter layout protocol and unbounded width errors. Strong answers trace how a child gets infinite width from a scrolling parent and fix it with a bounded wrapper. Red flag: blaming the child without tracing parent constraints.
Which DevTools view diagnoses janky Flutter animations?
Open Performance view; compare UI and Raster bars; flag bars over 16ms; blame UI bloat on builds and Raster jank on shaders or saveLayer. DevTools fluency and frame pipeline anatomy.
Walk me through Flutter's rendering pipeline and its phases.
Tests your understanding of the three-tree separation and how changes become pixels. Outline: setState marks objects dirty; Build updates elements, Layout computes sizes bottom-up via constraints, and Paint records commands top-down into layers.
Flutter's Widget, Element, and RenderObject trees: roles and relationships
Tests your mental model of Flutter's rendering layers. Strong answer: Widget is immutable configuration; Element is the mutable lifecycle manager owning the RenderObject; RenderObject is the concrete layout and paint entity.
Why use const for Flutter widgets and how does it improve performance?
Tests widget canonicalization and rebuild short-circuiting. Strong answer: const enables instance reuse and skips subtree rebuilds on parent updates, reducing allocations.
Debug iOS code signing failure in CI that works locally
This tests Xcode code signing and CI keychain isolation. A strong answer checks exportOptions.plist, keychain profile presence, runner OS and Xcode versions, and entitlements mismatches. Red flag: manual local fixes or ignoring keychain access gaps.
How do you handle platform-specific configurations per flavor on Android and iOS?
Tests if you know flavors delegate icons and titles to native tooling. On Android, use productFlavors in build.gradle with source sets or placeholders; on iOS, use Xcode build configurations with Info.plist values or asset catalogs.
Walk me through a Flutter CI/CD pipeline for Play Store and TestFlight
Tests your ability to orchestrate multi-platform Flutter builds, manage signing secrets, and automate deployments to Google Play Internal Testing and Apple TestFlight.
What does flutter build appbundle --release do to minimize size?
Dart AOT compiles and tree-shakes dead code; R8 shrinks Android Java/Kotlin; app bundles split by ABI. Fluency in the Flutter release pipeline and Dart-Android optimization boundaries.
How would you manage different backend environments in a Flutter project?
Tests Flutter build flavors and compile-time config injection. A strong answer uses dart-define or flavor-specific entry points plus an EnvironmentConfig abstraction. A red flag is manually swapping hard-coded base URLs before each build.
Flutter command for an Android release build and APK vs AAB difference.
Flutter CLI release commands and Android distribution formats. Name flutter build apk and flutter build appbundle; note AAB lets Google Play generate optimized APKs per device while APK is a single direct-install file.
How do you diagnose and fix flaky Flutter widget tests?
Audit unawaited futures, swap pumpAndSettle for explicit pumps or mock timers, and reproduce with logs. Deterministic control of Flutter async and animation timing. Retries or sleeps instead of removing timing leaks.
Get Flutter bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.