Flutter Savant¶
Overview¶
The Flutter Savant is a master expert with comprehensive, deep knowledge across the entire Flutter and Dart mobile development ecosystem. This Tier 1 orchestrator agent guides mobile application development from architecture to deployment, with expertise spanning Flutter SDK, Dart language, state management, native platform integration, iOS, Android, and modern Flutter development practices.
When to Use¶
Use the Flutter Savant when you need:
Architecture Decisions¶
- Choosing state management (BLoC vs Riverpod vs Provider vs GetX)
- App architecture (Clean Architecture, MVVM, feature-first)
- Navigation architecture (go_router vs Navigator 2.0)
- Database selection (Hive vs Isar vs SQLite vs Firestore)
- Firebase vs custom backend
Complex Flutter Problems¶
- Performance bottlenecks and optimization
- Platform channel integration (Swift/Kotlin)
- Complex state management scenarios
- Memory leak detection and resolution
- Animation performance issues
High-Level Technical Decisions¶
- Technology stack selection (Firebase vs Supabase vs custom backend)
- Code generation strategy (freezed, json_serializable, retrofit)
- Testing strategy (unit, widget, integration, golden tests)
- CI/CD pipeline setup (Codemagic vs GitHub Actions)
- App distribution strategy
Full-Stack Flutter Applications¶
- End-to-end Flutter app development
- Firebase integration (Auth, Firestore, Functions, Storage)
- GraphQL API integration
- Real-time features (chat, live updates, notifications)
- E-commerce applications
Native Platform Integration¶
- iOS-specific features (HealthKit, ARKit, Widgets)
- Android-specific features (WorkManager, Widgets, Android Auto)
- Platform-specific UI/UX patterns
- Method channels and platform views
Migration & Modernization¶
- Flutter version upgrades
- Null safety migration
- State management migration (Provider to Riverpod, etc.)
- Firebase migration (FlutterFire upgrades)
Core Expertise¶
Flutter SDK (3.x+)¶
- Framework Architecture: Widget tree, Element tree, RenderObject tree, build process
- Material Design 3: Material 3 theming, dynamic color, adaptive layouts
- Cupertino: iOS-style widgets, CupertinoNavigationBar, CupertinoTabScaffold
- Widgets: StatelessWidget, StatefulWidget, InheritedWidget, StreamBuilder, FutureBuilder
- Layout: Row, Column, Stack, Flex, Expanded, Flexible
- Advanced: CustomPaint, CustomScrollView, Slivers, Hero animations
- Platform Views: AndroidView, UiKitView for native UI integration
Dart Language (3.x+)¶
- Modern Dart: Null safety, sound type system, type inference
- Pattern Matching: Switch expressions, pattern matching, destructuring
- Records: Record types, positional and named fields
- Sealed Classes: Exhaustive pattern matching, algebraic data types
- Async/Await: Future, Stream, async*, sync*, yield
- Isolates: Concurrent programming, compute function
- Extension Methods: Adding functionality to existing types
State Management¶
- BLoC: flutter_bloc, Cubit, BlocProvider, BlocBuilder, BlocListener
- Riverpod: StateNotifier, FutureProvider, StreamProvider, family, autoDispose
- Provider: ChangeNotifier, Provider patterns, MultiProvider
- GetX: Get.find, GetBuilder, Obx, reactive state
- MobX: Observable state, reactions, computed values
- Redux: redux, flutter_redux, middleware
Navigation & Routing¶
- go_router: Declarative routing, deep linking, nested navigation, route guards
- Navigator 2.0: RouterDelegate, RouteInformationParser, declarative navigation
- Navigator 1.0: push, pop, pushNamed, MaterialPageRoute
- Deep Linking: URL schemes, universal links, app links
Platform Channels¶
- MethodChannel: Invoking platform-specific code (iOS/Android)
- EventChannel: Streaming data from native to Flutter
- FFI: Calling C/C++ code directly
- Pigeon: Type-safe platform channels with code generation
Firebase Integration¶
- Authentication: Email/password, OAuth (Google, Apple, Facebook), phone auth
- Cloud Firestore: Real-time database, queries, transactions, security rules
- Cloud Functions: Callable functions, HTTP triggers, background triggers
- Cloud Storage: File upload/download, storage references
- Analytics: Event tracking, user properties, audience segmentation
- Crashlytics: Crash reporting, custom logs, crash-free users
- Cloud Messaging: Push notifications, FCM, topic messaging
- Remote Config: Feature flags, A/B testing, dynamic configuration
Data Persistence¶
- shared_preferences: Key-value storage, user preferences
- sqflite: SQLite database, SQL queries, migrations
- Hive: Fast NoSQL database, type adapters, lazy boxes
- Isar: High-performance database, queries, indexes
- drift (moor): Type-safe SQL, migrations, reactive queries
- secure_storage: Encrypted storage, keychain/keystore
iOS & Android Development¶
- iOS: Swift, SwiftUI, UIKit, CocoaPods, Xcode, App Store submission
- Android: Kotlin, Jetpack Compose, Gradle, Android SDK, Play Store submission
DevOps & CI/CD¶
- Fastlane: Automated screenshots, beta deployment, app store submission
- Codemagic: Flutter CI/CD, cloud builds, workflows
- GitHub Actions: CI/CD pipelines, automated testing
- Firebase App Distribution: Beta testing, release management
Testing¶
- Unit Tests: test package, mocking with mockito
- Widget Tests: WidgetTester, find, pump, pumpAndSettle
- Golden Tests: Visual regression testing, goldens
- Integration Tests: integration_test, E2E testing
Architecture Decision Framework¶
State Management Selection¶
Use setState when: - Simple, local widget state - Few widgets, minimal state sharing - Learning Flutter, prototyping
Use Provider when: - Simple to medium app complexity - Want official Flutter solution - ChangeNotifier-based state
Use Riverpod when: - Medium to large applications - Want compile-time safety, no BuildContext - Need testing-friendly architecture - Migration from Provider
Use BLoC when: - Large enterprise applications - Want strict separation of concerns - Need event-driven architecture - Testing is top priority
Use GetX when: - Rapid development, prototyping - Want minimal boilerplate - Small to medium apps
Database Selection¶
Use shared_preferences when: - Simple key-value storage - User settings, preferences - Small data (<1MB)
Use Hive when: - Fast NoSQL database needed - Medium datasets (1-100MB) - Custom objects, type adapters - Offline-first apps
Use Isar when: - High-performance requirements - Large datasets (>100MB) - Complex queries, indexes - Reactive queries
Use sqflite when: - Relational data, SQL queries - Complex joins, migrations - Standard SQL compatibility
Use Firestore when: - Real-time sync required - Backend-as-a-service approach - No backend team - Scalability handled by Firebase
Navigation Architecture¶
Use go_router when: - Building new Flutter apps - Want declarative routing - Need deep linking out-of-the-box - Web support required - Route guards, redirects
Use Navigator 2.0 when: - Need full control over routing - Complex navigation requirements - Custom navigation patterns
Use Navigator 1.0 when: - Simple apps, basic navigation - Quick prototyping - Team familiar with imperative navigation
Code Examples¶
BLoC State Management¶
// counter_bloc.dart
class CounterBloc extends Bloc<CounterEvent, CounterState> {
CounterBloc() : super(const CounterState(count: 0)) {
on<CounterIncrementPressed>((event, emit) {
emit(CounterState(count: state.count + 1));
});
}
}
// counter_page.dart
class CounterPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (_) => CounterBloc(),
child: BlocBuilder<CounterBloc, CounterState>(
builder: (context, state) {
return Scaffold(
body: Center(child: Text('${state.count}')),
floatingActionButton: FloatingActionButton(
onPressed: () => context.read<CounterBloc>()
.add(CounterIncrementPressed()),
child: Icon(Icons.add),
),
);
},
),
);
}
}
Riverpod with Freezed¶
@freezed
class User with _$User {
const factory User({
required String id,
required String name,
required String email,
}) = _User;
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
}
final userProvider = FutureProvider.family<User, String>((ref, id) async {
final response = await http.get('/users/$id');
return User.fromJson(jsonDecode(response.body));
});
class UserPage extends ConsumerWidget {
final String userId;
@override
Widget build(BuildContext context, WidgetRef ref) {
final userAsync = ref.watch(userProvider(userId));
return userAsync.when(
data: (user) => Text('Hello, ${user.name}'),
loading: () => CircularProgressIndicator(),
error: (error, _) => Text('Error: $error'),
);
}
}
go_router Navigation¶
final router = GoRouter(
routes: [
GoRoute(
path: '/home',
builder: (context, state) => HomePage(),
routes: [
GoRoute(
path: 'profile',
builder: (context, state) => ProfilePage(),
),
],
),
GoRoute(
path: '/product/:id',
builder: (context, state) {
final id = state.pathParameters['id']!;
return ProductPage(productId: id);
},
),
],
);
Platform Channel Integration¶
class CryptoService {
static const platform = MethodChannel('com.example.app/crypto');
Future<String> encrypt(String data, String key) async {
final result = await platform.invokeMethod('encrypt', {
'data': data,
'key': key,
});
return result;
}
}
Interaction with Specialist Agents¶
The Flutter Savant can delegate to specialized agents:
- frontend-ui: UI/UX design, Material Design 3, accessibility
- backend-api: API design, GraphQL, REST endpoints
- database: Firestore schema, query optimization
- security: Authentication, encryption, secure storage
- qa-tester: Testing strategy, widget tests, integration tests
- deployment: CI/CD setup, Fastlane configuration
- performance: Performance profiling, optimization
- monitoring: Error tracking, analytics, crash reporting
Best Practices¶
Flutter Development Principles¶
- Widget Composition: Build complex UIs from simple, reusable widgets
- Immutability: Use const constructors, immutable state with freezed
- Separation of Concerns: Separate UI, business logic, and data layers
- Type Safety: Leverage Dart's type system, null safety
- Performance: 60 FPS, optimize builds, use const widgets
- Accessibility: Semantic widgets, screen reader support
Code Organization¶
lib/
├── core/ # Core utilities, theme
├── domain/ # Business logic, entities
├── data/ # Data layer, repositories
├── presentation/ # UI layer
│ ├── pages/
│ ├── widgets/
│ └── providers/
└── main.dart
Performance Best Practices¶
- const Widgets: Use const constructors wherever possible
- ListView.builder: Use builders for long lists
- RepaintBoundary: Isolate expensive widgets
- Compute Isolates: Heavy computation in background
- Image Optimization: Asset variants, caching
Security Best Practices¶
- Secure Storage: Use flutter_secure_storage for sensitive data
- HTTPS Only: Enforce HTTPS, certificate pinning
- Code Obfuscation: Use --obfuscate for release builds
- Biometric Auth: Use local_auth for sensitive operations
- Secrets Management: Never commit secrets, use dart-define
Invocation¶
Explicit Invocation¶
# Architecture decisions
Use flutter-savant to design a Flutter e-commerce app with offline support
# Technology selection
Use flutter-savant to choose between BLoC and Riverpod for state management
# Complex problems
Use flutter-savant to optimize app performance and reduce build time
Natural Language¶
Claude Code will automatically suggest the Flutter Savant when you mention: - Flutter architecture - Dart programming - State management (BLoC, Riverpod, Provider) - Firebase integration - Platform channels - Flutter performance
Related Agents¶
- react-native-savant: For React Native mobile development
- fullstack-js-savant: For full-stack JavaScript applications
- frontend-ui: For UI/UX design and component libraries
- backend-api: For backend API development
- security: For security audits and authentication
- qa-tester: For testing strategy and automation
- deployment: For CI/CD and app store deployment
- performance: For performance optimization