Use when you have a written implementation plan to execute in a separate session with review checkpoints
npx skills add DonggangChen/antigravity-agentic-skills --skill "mobile_flutter"
Install specific skill from multi-skill repository
# Description
Flutter/Dart best practices, Riverpod state management and performance optimization.
# SKILL.md
name: mobile_flutter
router_kit: FullStackKit
description: Flutter/Dart best practices, Riverpod state management and performance optimization.
metadata:
skillport:
category: development
tags: [architecture, automation, best practices, clean code, coding, collaboration, compliance, debugging, design patterns, development, documentation, efficiency, git, mobile flutter, optimization, productivity, programming, project management, quality assurance, refactoring, software engineering, standards, testing, utilities, version control, workflow] - mobile-react-native
π¦ Mobile Flutter
Flutter/Dart best practices and performance optimization.
π 1. Project Structure (Feature-First)
lib/
βββ core/
β βββ theme/
β βββ widgets/
βββ features/
β βββ auth/
β β βββ data/
β β βββ domain/
β β βββ presentation/
β βββ home/
βββ services/
βββ main.dart
π§© 2. Widget Best Practices
// β
use const constructor
class MyButton extends StatelessWidget {
const MyButton({super.key, required this.onPressed});
final VoidCallback onPressed;
@override
Widget build(BuildContext context) {
return ElevatedButton(onPressed: onPressed, child: Text('Click'));
}
}
// β
mark const widgets
const SizedBox(height: 16),
π¦ 3. State (Riverpod)
final authProvider = StateNotifierProvider<AuthNotifier, AuthState>((ref) {
return AuthNotifier(ref.watch(authRepositoryProvider));
});
class AuthNotifier extends StateNotifier<AuthState> {
AuthNotifier(this._repo) : super(const AuthState());
Future<void> login(String email, String password) async {
state = state.copyWith(isLoading: true);
final user = await _repo.login(email, password);
state = state.copyWith(user: user, isLoading: false);
}
}
β‘ 4. Performance
// β
ListView.builder (lazy loading)
ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) => ItemCard(item: items[index]),
)
// β
RepaintBoundary
RepaintBoundary(child: ExpensiveWidget())
// β
Isolate for CPU-heavy
final result = await compute(parseUsers, jsonString);
π 5. Secure Storage
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
final storage = FlutterSecureStorage();
await storage.write(key: 'token', value: token);
final token = await storage.read(key: 'token');
π± 6. Responsive
// MediaQuery
final isTablet = MediaQuery.of(context).size.width > 600;
// LayoutBuilder
LayoutBuilder(
builder: (context, constraints) {
return constraints.maxWidth > 600 ? WideLayout() : NarrowLayout();
},
)
Mobile Flutter v1.1 - Enhanced
π Workflow
Source: Flutter Engineering Best Practices & Riverpod Architecture
Phase 1: Architecture Setup
- [ ] Layering: Establish Feature-First structure (Presentation, Domain, Data).
- [ ] State Management: Use Riverpod
NotifierProviderand Code Generation (@riverpod). - [ ] Routing: Configure type-safe navigation and deep linking with GoRouter.
Phase 2: Implementation
- [ ] UI: Minimize rebuilds using
constconstructors. - [ ] Network: Write API layer (Interceptor, Error Handling) with Dio and Retrofit.
- [ ] Storage: Use
flutter_secure_storagefor sensitive data,IsarorHivefor cache.
Phase 3: Release & Quality
- [ ] Testing: Write Unit, Widget and Integration tests (including Golden Tests).
- [ ] Performance: Analyze "Jank" with DevTools (Shader compilation warm-up).
- [ ] CI/CD: Setup automated build and store upload processes with Fastlane.
Checkpoints
| Phase | Verification |
|---|---|
| 1 | Is Business logic completely separated from UI (Widgets)? |
| 2 | Is App cold start time < 2 seconds? |
| 3 | Does it behave responsively on different screen sizes (Tablet/Foldable)? |
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.