git-agent for Dart (Flutter)Conventional commits for Flutter widgets and Dart packages
git-agent understands Flutter widget trees, state management patterns (Riverpod, BLoC, Provider), and Dart package conventions, producing atomic conventional commits for mobile and cross-platform codebases.
diff example
diff --git a/lib/features/auth/providers/auth_provider.dart b/lib/features/auth/providers/auth_provider.dart
index 1f4a2c3..8e7b9d5 100644
--- a/lib/features/auth/providers/auth_provider.dart
+++ b/lib/features/auth/providers/auth_provider.dart
@@ -1,18 +1,24 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
-class AuthNotifier extends StateNotifier<AsyncValue<User?>> {
- AuthNotifier(this._authService) : super(const AsyncValue.data(null));
+part 'auth_provider.freezed.dart';
+part 'auth_provider.g.dart';
- final AuthService _authService;
+@freezed
+sealed class AuthState with _$AuthState {
+ const factory AuthState.initial() = _Initial;
+ const factory AuthState.authenticated(User user) = _Authenticated;
+ const factory AuthState.unauthenticated() = _Unauthenticated;
+}
- Future<void> login(String email, String password) async {
- state = const AsyncValue.loading();
- state = await AsyncValue.guard(() => _authService.login(email, password));
- }
+@riverpod
+class Auth extends _$Auth {
+ @override
+ AuthState build() => const AuthState.initial();
- Future<void> logout() async {
- await _authService.logout();
- state = const AsyncValue.data(null);
+ Future<void> login(String email, String password) async {
+ state = await AsyncValue.guard(() => userService.login(email, password));
+ state = AuthState.authenticated(user);
}
}git-agent output
refactor(auth): migrate to Riverpod code generation and freezed union state
- replace StateNotifier with Riverpod code-gen @riverpod annotation
- model auth state as sealed union (initial/authenticated/unauthenticated) via freezed
- generate part files for type-safe state handling
- simplify login method by removing manual loading state management
The raw StateNotifier required manual AsyncValue management and allowed
invalid state combinations; the sealed union makes impossible states
unrepresentable while the code-gen eliminates boilerplate.Why it works for Dart (Flutter)
- Understands Flutter widget tree rebuild patterns and state management architecture
- Recognises Riverpod, BLoC, and Provider patterns for accurate commit descriptions
- Separates Flutter asset and pubspec.yaml changes into dedicated commits
- Works with Flutter platform-specific code (android/, ios/) without mixing concerns
install
brew install gitagenthq/brew/git-agent
# inside your Flutter project
git-agent init # reads pubspec.yaml and lib/ structure for scope suggestionsFAQ
Does git-agent handle Flutter's generated code (freezed, json_serializable)?Yes. Generated .freezed.dart and .g.dart files are recognised as build artefacts. git-agent commits them alongside their source definition rather than treating them as separate unrelated changes.
How does git-agent handle Flutter platform channel changes?Dart-side MethodChannel definitions and the native counterpart (Swift/Kotlin) are kept in separate commits, as they belong to the Flutter module and the platform-specific module respectively.
Can git-agent work with Flutter monorepos (melos, pub workspaces)?Yes. git-agent detects melos and pub workspace configurations and suggests scopes per package. Changes to different packages within the same commit are split into separate commits.