flutter-std
Build and debug Flutter/Dart apps with Riverpod (codegen), Freezed, and GoRouter. Use when implementing Flutter features, running apps, hot reload/restart, or debugging UI.
When & Why to Use This Skill
This Claude skill is a comprehensive development suite for Flutter and Dart, specifically optimized for modern state management and architectural patterns. It streamlines the creation, debugging, and maintenance of mobile applications by integrating Riverpod (codegen), Freezed, and GoRouter. By automating repetitive tasks like code generation, dependency injection setup, and UI debugging, it ensures high-quality code adherence to strict architectural standards while significantly reducing manual boilerplate and troubleshooting time.
Use Cases
- Automated Code Generation: Quickly generate immutable data models and type-safe state providers using Freezed and Riverpod to minimize manual coding errors.
- Efficient App Lifecycle Management: Execute app launches, hot reloads, and hot restarts directly through the agent to speed up the UI/UX iteration cycle.
- Advanced UI & Logic Debugging: Inspect the Flutter widget tree, analyze runtime logs, and resolve complex UI issues using integrated Dart Tooling Daemon (DTD) support.
- Architectural Standardization: Enforce a clean 'UI-Actions-Utils' extension pattern and a standardized project structure to ensure long-term maintainability and team scalability.
- Database & Navigation Setup: Rapidly implement structured SQLite storage and declarative routing with GoRouter, following best practices for mobile navigation and data persistence.
| name | flutter-std |
|---|---|
| description | Build and debug Flutter/Dart apps with Riverpod (codegen), Freezed, and GoRouter. Use when implementing Flutter features, running apps, hot reload/restart, or debugging UI. |
Flutter Std Tools
When to use
- Use when the user is working on Flutter/Dart features, running the app, hot reload/restart, or debugging UI.
- Use when requests mention Riverpod, Freezed, GoRouter, or Flutter widget structure.
Instructions
- Setup: Ensure the project root is added via
dart___add_roots. List devices withdart___list_devicesbefore launching. - Run & lifecycle: Use
dart___launch_appto run on a device. Usedart___hot_reloadfor UI changes (preserves state) anddart___hot_restartfor logic/state resets. Avoidflutter runvia shell. Stop apps withdart___stop_app. - Debug & inspect: Connect DTD with
dart___connect_dart_tooling_daemonwhen needed. Usedart___get_widget_tree,dart___get_runtime_errors, anddart___get_app_logs. - Testing & maintenance: Run tests with
dart___run_tests. Manage deps viadart___pub. Analyze/fix withdart___analyze_filesanddart___dart_fix. - Code generation:
dart run build_runner build --delete-conflicting-outputs(one-time) ordart run build_runner watch --delete-conflicting-outputs(watch).
Requirements
Architecture & tech stack
- State Management: Must use Riverpod with code generation (
@riverpod). - Data Models: Must use Freezed for immutable data classes and unions.
- Dependency Injection: Must use GetIt and Injectable for service location.
- Routing: Must use GoRouter for navigation (declarative routing).
- Database: Must use SQLite for structured data storage.
- Widget State Structure (Stateful/Stateless): Follow the Widget State Structure section below and split widget classes into UI, Actions, and Utils extensions.
Project Structure
- core/ - Core services and singletons
- config/ - App configuration
- di/ - Dependency injection setup (GetIt/Injectable)
- routing/ - GoRouter configuration
- utils/ - General utilities
- data/ - Data models and storage
- consts/ - Constant definitions
- models/ - Freezed data models
- providers/ - Riverpod providers (using code generation)
- repos/ - Data access layer
- services/ - External services (API, Database, etc.)
- views/ - UI components and pages
- pages/ - Main pages
- widgets/ - Reusable widgets
- pops/ - Popups and dialogs
- app.dart - App entry point widget
- main.dart - Main entry file
Additional guidelines
- Formatting: Do NOT run
dart format. Follow the project's existing code style. - Deprecations: Replace all
Color.withOpacityusage withColor.withValues(Flutter 3.27+). - Testing:
utilsclasses require unit test coverage.
Widget State Structure (Stateful/Stateless)
To maintain clean and manageable code, split widget classes into three parts using extensions within the same file. This applies to both StatefulWidget (State class) and StatelessWidget (the widget class), separating UI from logic and event handling.
Structure
- UI: The main
Stateclass containing thebuild()method and widget definitions. - Actions: An extension on the
Stateclass for event handlers (e.g.,_onTap,_submit). - Utils: An extension on the
Stateclass for private helper methods and business logic.
Example (StatefulWidget)
import 'package:flutter/material.dart';
class MyPage extends StatefulWidget {
const MyPage({super.key});
@override
State<MyPage> createState() => _MyPageState();
}
// 1. UI - Main State Class
class _MyPageState extends State<MyPage> {
final _controller = TextEditingController();
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('My Page')),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
TextField(
controller: _controller,
decoration: const InputDecoration(labelText: 'Enter text'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: _onSubmit, // Reference to Actions extension
child: const Text('Submit'),
),
],
),
),
);
}
}
// 2. Actions - Event Handlers
extension _MyPageActions on _MyPageState {
void _onSubmit() {
final text = _controller.text;
if (_validateInput(text)) { // Reference to Utils extension
_showSuccessDialog(text);
} else {
_showErrorSnackBar();
}
}
void _showSuccessDialog(String text) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('Success'),
content: Text('You entered: $text'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
}
}
// 3. Utils - Helper Methods & Logic
extension _MyPageUtils on _MyPageState {
bool _validateInput(String text) {
return text.isNotEmpty && text.length > 3;
}
void _showErrorSnackBar() {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Input must be at least 4 characters')),
);
}
}
Example (StatelessWidget)
import 'package:flutter/material.dart';
class MyStatelessPage extends StatelessWidget {
const MyStatelessPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('My Stateless Page')),
body: Center(
child: ElevatedButton(
onPressed: () => _onSubmit(context), // Reference to Actions extension
child: const Text('Submit'),
),
),
);
}
}
// 2. Actions - Event Handlers
extension _MyStatelessPageActions on MyStatelessPage {
void _onSubmit(BuildContext context) {
if (_validateInput('ok')) { // Reference to Utils extension
_showSuccessDialog(context);
} else {
_showErrorSnackBar(context);
}
}
void _showSuccessDialog(BuildContext context) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('Success'),
content: const Text('Submitted.'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
}
}
// 3. Utils - Helper Methods & Logic
extension _MyStatelessPageUtils on MyStatelessPage {
bool _validateInput(String text) {
return text.isNotEmpty;
}
void _showErrorSnackBar(BuildContext context) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Invalid input')),
);
}
}
Example prompts
- "Run the flutter app on the iOS simulator"
- "Hot reload the app to show the new colors"
- "Create a new Riverpod provider for user authentication using code gen"
- "Implement a settings page using the project's existing preferences store"
- "Add a SQLite table for storing todo items"
- "Add a new route for the profile page using GoRouter"
- "Fix analysis errors in the project"
- "Generate a Freezed model for User with name and age fields"