Flutter
294 bites tagged Flutter — interview questions with model answers, and 60-second explainers.
Android App Signing: Your App's Digital Seal
Think of app signing as a digital seal for your Android app. It proves you are the author and the code hasn't been tampered with, a mandatory step for Google Play release. The biggest footgun is losing your private key, which locks you out of.
flutter analyze: Your Code's First Line of Defense
Think of `flutter analyze` as a spell-checker for your Dart code. It catches errors, style issues, and potential bugs before you run the app. The footgun is ignoring its configuration; its real power is in a custom `analysis_options.yaml` file.
Flutter Build Modes: Debug, Profile, and Release
Flutter's build modes trade performance for developer features. Debug mode is for fast iteration with hot reload, while Release is for optimized user builds. You use Debug daily, Profile to hunt for bottlenecks, and Release to ship.
Testing Flutter Platform Channel Interactions
Mock platform channels to test your Dart code's interaction with native APIs without a real device. Use this for unit tests of features like camera or GPS access. Footgun: These tests only verify the Dart side, not that your native code is correct.
Golden File Testing: Visual Regression for Widgets
Golden file testing is a 'spot the difference' game for your UI, catching visual regressions by comparing a widget's rendering to a master image. Use it to lock down critical widget appearances.
WidgetTester: Programmatically Drive Your Flutter UI
WidgetTester is a robot user for your app, programmatically tapping, dragging, and entering text. Use it in `testWidgets` to simulate user flows and verify UI state. The footgun is forgetting `tester.pump()` after an action; you'll assert against a stale UI.
Finding Widgets with Flutter's Finder Class
Finder is your magnifying glass for widget tests, letting you locate specific widgets in the tree. It describes what to find, while the WidgetTester does the actual finding. The footgun is assuming a finder returns only one widget when it might match several.
Dart's `expect` and Matchers: Writing Better Tests
Dart's `expect` and Matchers are a grammar for your tests, letting you define complex rules beyond simple equality. Use them to verify values, check for exceptions, and test async Futures/Streams.
Unit Testing in Dart: Verify Your Logic in Isolation
A unit test is a microscope for your code. It checks a single function or class in isolation, ensuring it behaves correctly without worrying about the UI or network. Use it for business logic, not for testing rendered widgets or API calls.
Background Execution and Services in Flutter
Think of background execution as a helper doing heavy lifting off-screen. It keeps your app's UI smooth by running tasks like data processing on a separate thread (Isolate). The footgun is that isolates don't share memory; you must pass data explicitly.
BasicMessageChannel: A Coded Pipe to Native
A BasicMessageChannel is a raw data pipe between Dart and native code that uses a "codec" to translate objects into binary. Use it for streaming data or custom types not handled by MethodChannel. The footgun is a codec mismatch, which causes runtime crashes.
Flutter Add-to-App: Embedding Flutter in Native Apps
Think of Add-to-App as embedding the Flutter engine inside your existing native app, like a super-powered web view. It's for incrementally migrating a large Android or iOS codebase to Flutter without a full rewrite.
Pigeon: Type-Safe Platform Channels in Flutter
Pigeon acts like a contract for your app's native code, generating type-safe platform channels from a single definition. This replaces manual, error-prone MethodChannel code. The footgun: Swift types default to structs; use `@SwiftClass` for class features.
Platform Views: Embedding Native UI in Flutter
Platform Views cut a hole in your Flutter UI to show a native component. Use them to embed UI that can't be rebuilt in Dart, like Google Maps or a native WebView. Be warned: they are resource-heavy and can hurt performance if overused.
Flutter Platform Channels: Talking to Native Code
Platform Channels are a telephone line between your Dart code and native device APIs. Use them to access features like battery level or integrate a native SDK not available in Dart.
Dart's Platform Class: Querying the Host Environment
Think of Dart's `Platform` class as a runtime detective for your app. It answers "where am I running?" by checking the OS, environment variables, and more. Use it to show different UI on iOS vs. Android.
Flutter: Requesting Runtime Permissions
Don't assume your app has access to the camera or contacts; you must ask the user for permission at runtime. This is required for features like photo uploads or location tracking. The common footgun is forgetting to declare permissions in native config files.
Flutter Packages: Bridging Dart to Native Features
Think of packages as pre-built bridges to native device features. They let your Dart code access the camera or GPS without you writing the complex, platform-specific code.
Canvas Transformations: Moving the Paper, Not the Pen
Think of Flutter's Canvas transformations not as moving your drawing, but as moving the coordinate system itself. This is key for custom painters, like rotating the canvas to draw tick marks on a dial.
Flutter's Physics Simulations: The Simulation Class
Flutter's `Simulation` class is the engine for physics-based animations, modeling a 1D object's position and velocity over time. It powers realistic scrolling, springs, and gravity effects.
Flutter's Path Class: Drawing Custom Shapes
Flutter's Path is a digital pen for drawing any custom shape. Use it for complex icons, charts, or clipping widgets into non-rectangular forms. The footgun: forgetting `moveTo` will connect separate parts of your drawing with an unwanted line.
Staggered Animations: Choreographing UI Changes
A staggered animation is a domino effect for your UI. Instead of animating everything at once, you sequence animations with slight delays for a more fluid, polished feel. Use it for list items appearing one by one. The footgun is timing: too long feels slow.
ClipPath: Clip Widgets to Custom Shapes
ClipPath is a stencil for your widgets. It cuts a child widget to a custom-defined shape, hiding anything outside the lines. Use it for complex shapes like waves or stars, but avoid it for simple rectangles or circles—it's expensive.
CustomPaint: Drawing Your Own Widgets in Flutter
CustomPaint is your blank canvas widget; CustomPainter is the artist that draws on it. Use them for custom charts or unique UI. The footgun: shared canvases can cause blend modes to erase other widgets, so use `saveLayer` sparingly.
Get Flutter bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.