tezvyn:

Flutter & Dart

Flutter framework, Dart language, packages, Impeller

307 bites

More in Flutter & Dart — page 8

Flutter & Dart2 min read

Tree Shaking Removes Unused Flutter Code

Tree shaking is the compiler deleting code your app never calls, so importing a massive package only costs the pieces you use. It runs automatically in release builds. Relying on dynamic dispatch or dart:mirrors silently disables it and brings back the bloat.

Flutter & Dart2 min read

Legacy Integration Testing with flutter_driver

flutter_driver remotely pilots your app from a host via Dart VM service, common in legacy codebases with host-side scripts. Do not treat it as an in-process widget test because it runs outside the app; you cannot inspect state or use flutter_test matchers.

Flutter & Dart2 min read

Repository Pattern: Hide Your Data Sources

A repository is a contract that hides where your data lives. Your Flutter app should not care if a user profile comes from Firebase, SQLite, or a mock. Engineers often leak HTTP clients or database models into UI instead of returning domain models.

Flutter & Dart2 min read

Flutter Network Errors: Fail Gracefully

Treat every network call as a promise that might break. In Flutter, catch exceptions at the HTTP boundary and map them to UI states like retry widgets. The footgun is letting Dio or http exceptions bubble up, crashing the app instead of degrading gracefully.

Flutter & Dart2 min read

Full-Text Search in Local Flutter Databases

SQLite FTS5 is an inverted index in your app: words map to row IDs, skipping brute-force scans. Use it when local tables exceed thousands of rows and LIKE lags. The footgun is that FTS virtual tables never auto-sync, so stale indexes return wrong rows.

Flutter & Dart2 min read

Passing Arguments to Flutter Named Routes

Flutter named routes pass data through an arguments field instead of global variables. Use this when navigating to a route that needs an ID or configuration object. Arguments are untyped by default, so unsafe casts crash at runtime.

Flutter & Dart2 min read

Performance Profiling in Tests

Performance profiling in tests means capturing frame build and raster times during a scripted, automated run instead of eyeballing smoothness, so jank regressions get caught in CI before they ever reach a real device.

Flutter & Dart2 min read

Flutter Nested Navigation: Routers Within Routers

Nested Navigation is like having a mini-app with its own back button inside a single screen. It's used for UIs like a BottomNavigationBar where each tab needs its own navigation history. The footgun is calling the wrong Navigator's context.

Flutter & Dart2 min read

Flutter's `compute`: Offload Heavy Work from the UI Thread

Flutter's `compute` function runs heavy calculations in the background to prevent your app's UI from freezing. Use it for tasks like parsing large JSON or complex math. The footgun: on the web, it runs on the same event loop, not in a true parallel thread.

Flutter & Dart2 min read

Flutter for Web: Build and Deploy

Flutter for Web compiles your Dart code into a web app. Use `flutter build web` and choose a renderer: HTML for smaller size or CanvasKit for performance. The footgun is the initial download size, which can be large and slow down first-page load.

Flutter & Dart2 min read

Generating Code Coverage Reports in Dart

Code coverage shows which lines your tests execute. It's a health check for your test suite's reach, not a measure of code quality. Use the `coverage` package to generate reports for CI/CD. The footgun is that high coverage doesn't prove correctness.

Flutter & Dart2 min read

Mocking Dependencies in Flutter with Mockito

Mockito creates fake, controllable versions of your app's dependencies, like an API client. This is crucial for unit tests, letting you isolate code from external systems to make tests fast, reliable, and independent of network or database availability.

Flutter & Dart2 min read

Flutter Widget Testing: Verifying UI in Isolation

Widget testing is like testing a single actor's performance without the full play. It lets you build, interact with, and verify a single UI component in isolation, making it faster than a full app test and more comprehensive than a unit test.

Flutter & Dart2 min read

EventChannel: Streaming Data from Native to Flutter

EventChannel is a one-way radio from native code to your Flutter app, designed for continuous event streams, not single method calls. Use it to listen for ongoing platform events like sensor data, GPS location updates, or battery state changes.

Flutter & Dart2 min read

Flutter Shaders: GPU Power for Custom Graphics

Shaders are small programs running on the GPU to create custom visual effects. Use them for high-performance graphics like frosted glass or animated gradients that standard widgets can't handle.

Flutter & Dart2 min read

Choosing a Flutter Local Persistence Strategy

Flutter offers three main ways to persist data locally. Your options are simple key-value pairs for settings, direct file I/O for blobs like images, or a full SQLite database for complex, structured data. The main footgun is picking the wrong tool for the job.

StateNotifierProvider: Manage Immutable State
Flutter & Dart2 min read

StateNotifierProvider: Manage Immutable State

StateNotifierProvider bundles immutable state with the logic to change it. It's ideal for managing complex objects like a todo list by exposing methods like `addTodo`.

BLoC Pattern: Separating UI from Business Logic
Flutter & Dart2 min read

BLoC Pattern: Separating UI from Business Logic

The BLoC pattern treats app state as a stream: events go in, states come out. Use it in Flutter for complex state like user auth or data fetching. The footgun is overusing it for simple UI state, which creates unnecessary boilerplate.

Flutter & Dart2 min read

Flutter's onGenerateRoute for Dynamic Routes

onGenerateRoute is Flutter's central switchboard for creating routes on the fly, especially when they need data. Use it to pass arguments to new screens or handle routes not statically defined in the `routes` map.

Flutter & Dart2 min read

Deep Linking: URLs for Your App's Screens

Deep linking gives your app screens their own URLs, letting users jump directly to specific content from outside the app. Use it for email marketing, sharing content, or push notifications.