Core Packages¶
Bond's core packages provide production-ready solutions for common Flutter development challenges. Each package is designed to work seamlessly together while remaining independently useful.
🔥 BondFire - Networking¶
Type-safe HTTP client with automatic serialization, caching, and error handling.
// Simple API call with automatic JSON conversion
final users = await bondFire
.get<ListResponse<User>>('/users')
.factory(ListResponse<User>.fromJson)
.cache(duration: Duration(minutes: 5))
.execute();
Key Features: - ✅ Type-safe requests and responses - ✅ Automatic JSON serialization/deserialization - ✅ Built-in caching with TTL - ✅ Custom error handling - ✅ Request/response interceptors - ✅ Retry mechanisms
📝 Bond Forms¶
Declarative forms with validation, state management, and API integration.
// Create form with validation rules
final form = BondFormState(fields: {
'email': TextFieldState('', rules: [Rules.required(), Rules.email()]),
'password': TextFieldState('', rules: [Rules.required(), Rules.minLength(8)]),
});
// Submit to API
final result = await controller.submit(api.login);
Key Features: - ✅ Declarative field definitions - ✅ 15+ built-in validation rules - ✅ State management integrations (Riverpod, Bloc, GetX) - ✅ Multi-step stepper forms - ✅ Localized error messages - ✅ Direct API integration
💾 Bond Cache¶
Unified caching with pluggable drivers and computation helpers.
// Simple key-value caching
await Cache.put('user_preferences', preferences, expiredAfter: Duration(hours: 24));
final prefs = Cache.get<UserPreferences>('user_preferences');
// Cache expensive computations
final users = await Cache.remember('users_list', Duration(minutes: 5), () => api.fetchUsers());
Key Features:
- ✅ Multiple cache drivers (Memory, SharedPreferences, Custom)
- ✅ Object caching with JSON factories
- ✅ TTL (time-to-live) support
- ✅ Computation caching with remember()
- ✅ Multiple cache stores
- ✅ Observable cache changes
📊 Bond Analytics¶
Event-driven analytics with provider adapters and system events.
// Define custom events
class PurchaseEvent extends AnalyticsEvent {
PurchaseEvent({required this.productId, required this.amount});
final String productId;
final double amount;
@override String get key => 'purchase_completed';
@override Map<String, dynamic> get params => {
'product_id': productId,
'amount': amount,
};
}
// Fire events
AppAnalytics.fire(PurchaseEvent(productId: 'premium_plan', amount: 29.99));
Key Features: - ✅ Type-safe event definitions - ✅ System event mixins - ✅ Provider adapters (Firebase, custom) - ✅ User context management - ✅ Structured parameters - ✅ Debug capabilities
🔔 Bond Notifications¶
Unified push and local notifications with routing and actions.
// Define typed notifications
class OrderUpdated extends PushNotification with ActionablePushNotification {
@override List<String> get code => ['order_placed', 'order_delivered'];
@override void onTap(Map<String, dynamic> data) {
// Handle notification tap
Navigator.pushNamed(context, '/orders/${data['order_id']}');
}
}
// Register in service provider
class OrderServiceProvider extends ServiceProvider with PushNotificationServiceProviderMixin {
@override List<PushNotification> get pushNotifications => [OrderUpdated()];
}
Key Features: - ✅ Push notifications with Firebase - ✅ Local notifications - ✅ Typed notification handlers - ✅ Actionable notifications with routing - ✅ Notification channels - ✅ Foreground/background handling
🔐 Bond Authentication¶
Complete authentication flows with secure token management and route guarding.
// Authentication service provider
class AuthServiceProvider extends ServiceProvider with ResponseDecoding {
@override
Future<void> register(GetIt it) async {
it.registerLazySingleton(() => AuthApi(it()));
it.registerLazySingleton(() => TokenManager(it()));
}
@override
Map<Type, JsonFactory> get factories => {
User: User.fromJson,
AuthResponse: AuthResponse.fromJson,
};
}
// Login form with validation
final loginForm = BondFormState(fields: {
'email': TextFieldState('', rules: [Rules.required(), Rules.email()]),
'password': TextFieldState('', rules: [Rules.required(), Rules.minLength(8)]),
});
Key Features: - ✅ Complete authentication flows - ✅ Secure token storage and refresh - ✅ Form-based login/registration - ✅ Route guarding and protection - ✅ Social authentication support - ✅ Biometric authentication
🔄 Package Integration¶
Bond packages are designed to work together seamlessly:
Forms + Networking¶
// Submit form directly to API
final result = await controller.submit((data) =>
bondFire.post<User>('/register')
.body(data.toJson())
.factory(User.fromJson)
.execute()
);
Networking + Caching¶
// Automatic caching with BondFire
final users = await bondFire
.get<ListResponse<User>>('/users')
.factory(ListResponse<User>.fromJson)
.cache(duration: Duration(minutes: 5)) // Uses Bond Cache automatically
.execute();
Analytics + Authentication¶
// Track authentication events
class LoginEvent extends AnalyticsEvent with UserLoggedIn {
@override String get key => 'user_logged_in';
@override Map<String, dynamic> get params => {'method': 'email'};
}
AppAnalytics.setUserId(user.id);
AppAnalytics.fire(LoginEvent());
🚀 Getting Started¶
- Install Bond CLI - Scaffold projects with all packages pre-configured
- Environment Setup - Configure your development environment
- Service Providers - Understand Bond's architecture
- Choose your packages - Start with BondFire and Forms, add others as needed
📚 Next Steps¶
- New to Bond? Start with BondFire Networking for API integration
- Building forms? Jump to Bond Forms for validation and state management
- Need caching? Explore Bond Cache for performance optimization
- Want analytics? Check out Bond Analytics for event tracking
💡 Best Practices¶
- Use Service Providers to register and configure each package
- Leverage type safety - define your models and let Bond handle the rest
- Start simple - Bond packages provide sensible defaults for quick setup
- Combine packages - they're designed to work together seamlessly
- Follow conventions - Bond's patterns scale from simple to complex applications
Ready to build production-ready Flutter apps with Bond's core packages? Let's start! 🚀