Skip to content
tezvyn:

All bites

The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.

4247 bites

Page 10

Flutter & Dart2 min read

Flutter's Router API: Declarative Navigation

The Router API treats navigation as state. You declare the page stack based on app state, giving you full control over URLs and the back button. This is vital for web/desktop apps but introduces significant boilerplate compared to simple push/pop navigation.

Flutter & Dart2 min read

Flutter Hero Animations: Guiding the User's Eye

A Hero animation makes a widget appear to fly from one screen to another, connecting two UIs. It's perfect for transitioning a thumbnail to a detail page, guiding the user's focus. The main footgun is using non-unique tags, which causes animations to fail.

Flutter & Dart2 min read

PageRouteBuilder: Custom Routes Without the Boilerplate

PageRouteBuilder creates a custom page route on the fly, skipping the boilerplate of a full subclass. Just provide a pageBuilder for the screen's content and a transitionsBuilder for a unique animation.

Flutter & Dart2 min read

PopScope: Guarding Your Flutter Routes

PopScope acts as a gatekeeper for back navigation in Flutter, letting you intercept and block attempts to leave a screen. Use it to show a confirmation dialog for unsaved changes. Its behavior differs on iOS; the swipe-back gesture won't trigger its callback.

Flutter & Dart2 min read

Provider: Pass Data Down Your Widget Tree

Think of Provider as a delivery service for your app's data, passing it down the widget tree without sending it through every widget's constructor. It's a lightweight way to manage state. The footgun: never use .value to create a new object.

Flutter & Dart2 min read

ValueNotifier: Notifies on Replacement, Not Mutation

ValueNotifier is a simple state holder that tells widgets to rebuild when its single value is replaced. It's great for immutable data like a boolean toggle or counter.

Cubit: Simple State Management in Flutter
Flutter & Dart2 min read

Cubit: Simple State Management in Flutter

A Cubit is a simple state manager that exposes functions to directly trigger state changes. It's ideal for managing local UI state, like a counter or form data, without the complexity of events. The footgun is expecting state to update synchronously.

Riverpod: Compile-Safe, Reactive State Management
Flutter & Dart2 min read

Riverpod: Compile-Safe, Reactive State Management

Riverpod treats app state like a reactive formula. Define a piece of data once, and Riverpod automatically updates any UI that depends on it. It's ideal for network requests and shared state. Footgun: Watching a provider rebuilds the UI on every change.

GetX State Management: Simplicity Over Boilerplate
Flutter & Dart2 min read

GetX State Management: Simplicity Over Boilerplate

GetX simplifies Flutter state management by removing boilerplate and avoiding code generators. It offers both simple manual updates and a reactive style. Use it for rapid development where minimal setup is key.

Flutter & Dart2 min read

Redux: Predictable State via a Single Source of Truth

Redux treats app state like a transaction log. All changes are explicit actions processed by pure functions, creating a new, predictable state. It's ideal for complex apps with shared state. The main footgun: putting side effects like API calls in reducers.

MobX: Automatic UI Updates with Reactive State
Flutter & Dart2 min read

MobX: Automatic UI Updates with Reactive State

MobX automatically wires your reactive data to your Flutter UI, so widgets update when data changes. It's used for state management from simple counters to complex forms. The main footgun is forgetting to wrap all state mutations inside an Action.

Flutter & Dart2 min read

Freezed: Immutable State Without Boilerplate

Freezed is a Dart code generator that writes your immutable data classes for you. You define the shape, and it generates constructors, copyWith, and equality checks. Use it for model classes and to represent distinct states.

Flutter & Dart2 min read

Dart's `http` Package: Simple Requests vs. Composable Clients

Dart's http package simplifies web requests. Use top-level functions like http.get() for one-off calls, or a Client for persistent connections. Forgetting to call client.close() is a common footgun that leaks resources.

Flutter & Dart2 min read

JSON in Dart: Using `dart:convert`

dart:convert is Dart's built-in translator for JSON. It turns Dart Maps into JSON strings (jsonEncode) for APIs and file storage, and parses JSON strings back into Maps (jsonDecode). The footgun: jsonDecode returns a generic Map, not your custom class.

Flutter & Dart2 min read

Manual JSON Serialization with fromJson/toJson

Manually map your Dart objects to JSON by writing your own fromJson and toJson methods. This is ideal for simple data models or quick prototypes where code generation is overkill.

Flutter & Dart2 min read

FutureBuilder: Handling Async UI in Flutter

FutureBuilder rebuilds UI based on an async operation's state, showing loading, error, or data. Use it for network requests or slow computations. Footgun: Never create the Future inside build; it will restart on every rebuild, causing an infinite loading…

Flutter & Dart2 min read

json_serializable: Automating JSON in Dart

json_serializable is a boilerplate-writing robot for Dart, automatically generating code to convert classes to and from JSON. It's essential for data models in network requests or local storage.

Flutter & Dart2 min read

dio Interceptors: Middleware for Network Requests

dio Interceptors are middleware for network requests, letting you inspect and modify them before they're sent or after a response is received. Use them to globally add auth tokens, log activity, or handle token refreshes.

Flutter & Dart2 min read

graphql_flutter: Client Setup and Querying

graphql_flutter connects your app to a GraphQL API via a client-provider-widget pattern. You provide a configured GraphQLClient to a GraphQLProvider, then use Query widgets to fetch data declaratively.

Flutter & Dart2 min read

Cross-Platform WebSockets with `web_socket_channel`

The web_socket_channel package abstracts away platform differences for WebSockets, giving you a single API for web, mobile, and server. Use it for real-time features like chat or live data feeds. The footgun: always await channel.ready before sending data.