- Home
- Skills
- Madteacher
- Mad Agents Skills
- Flutter Networking
flutter-networking_skill
17
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill madteacher/mad-agents-skills --skill flutter-networking- SKILL.md7.6 KB
Overview
This skill provides comprehensive Flutter networking guidance for building robust, performant network layers in Dart apps. It covers HTTP CRUD operations, WebSocket real-time communication, authentication headers and token patterns, error handling, background parsing, and integration with common app architectures. The content focuses on practical code patterns, service/repository organization, and performance optimizations for production apps.
How this skill works
The skill explains how to perform GET, POST, PUT, and DELETE requests using the http package and how to add authorization headers for Bearer, Basic, or API key flows. It shows WebSocket setup with web_socket_channel for real-time streams and demonstrates sending/receiving messages. It also describes error handling strategies, retry/exponential backoff, and offloading heavy JSON parsing to background isolates via compute(). Examples include service and repository layers to keep network concerns separated from UI.
When to use it
- Implement standard REST CRUD endpoints (GET, POST, PUT, DELETE) in Flutter apps.
- Add authenticated API calls with Bearer tokens, Basic auth, or API keys.
- Build real-time features or bi-directional messaging with WebSockets.
- Parse large JSON payloads off the main thread using isolates.
- Integrate networking into MVVM/Repository architectures for testability.
Best practices
- Use typed model classes with fromJson/toJson and parse large responses with compute().
- Centralize HTTP calls in a service layer and expose data via repositories.
- Handle all relevant HTTP status codes and surface clear, typed exceptions.
- Apply retry and exponential backoff for transient failures and set timeouts.
- Secure tokens (never hard-code), use headers for auth, and cache responses where appropriate.
Example use cases
- Fetch lists and detail pages with FutureBuilder and a Repository-backed service.
- Create and update resources via POST/PUT with Content-Type: application/json headers.
- Authenticate requests with Bearer tokens and refresh on 401 responses.
- Stream chat messages or live updates using WebSocketChannel and StreamBuilder.
- Improve performance by parsing large photo lists in background isolates.
FAQ
Use compute() to run JSON parsing in a background isolate and return typed models to the UI.
What's the recommended way to handle expired tokens?
Detect 401 responses, refresh the token via an auth service, retry the original request, and fallback to login if refresh fails.
When should I use WebSockets instead of polling?
Use WebSockets for frequent, low-latency updates or two-way messaging; use polling for infrequent or simple periodic refreshes.