Get up and running with Flutter Infra in minutes!
Add to your pubspec.yaml:
dependencies:
flutter_infra: ^0.0.1import 'package:flutter_infra/flutter_infra.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize storage service
final storageService = await StorageService.create();
// Basic operations
await storageService.setString('username', 'john_doe');
final username = await storageService.getString('username');
// Secure storage for sensitive data
await storageService.setSecureString('api_token', 'secret_token');
final token = await storageService.getSecureString('api_token');
runApp(MyApp());
}final storageService = await StorageService.create();
// JSON Operations
await storageService.setJson('user_profile', {
'name': 'John Doe',
'email': 'john@example.com',
'preferences': {'theme': 'dark'}
});
final profile = await storageService.getJson('user_profile');
// String Lists
await storageService.setStringList('interests', ['tech', 'music', 'travel']);
final interests = await storageService.getStringList('interests');
// DateTime Operations
await storageService.setDateTime('last_login', DateTime.now());
final lastLogin = await storageService.getDateTime('last_login');import 'package:flutter_infra/flutter_infra.dart';
// Create network service
final networkService = await NetworkService.create(
config: NetworkConfig(
baseUrl: 'https://api.example.com',
enableLogging: true,
),
);
// Make API calls
final response = await networkService.getJson('/users/profile');
await networkService.postJson('/users/update', jsonBody: {'name': 'John'});// Create storage for token management
final storageService = await StorageService.create();
// Create network service with token support
final networkService = await NetworkService.createWithTokenSupport(
config: NetworkConfig(
baseUrl: 'https://api.example.com',
enableLogging: true,
),
tokenManager: DefaultTokenManager(storage: storageService),
);
// Tokens are automatically managed
final userProfile = await networkService.getJson('/protected/profile');final storageService = await StorageService.create(
config: StorageConfig(
enableLogging: true,
enableCache: true,
encryptionKey: 'your-encryption-key',
),
);final networkService = await NetworkService.create(
config: NetworkConfig(
baseUrl: 'https://api.example.com',
enableLogging: true,
timeout: Duration(seconds: 30),
defaultHeaders: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
),
);Check out the example directory for a complete Flutter app demonstrating:
- Default Usage: Basic storage and network operations
- Common Usage: Token management and API integration
- Advanced Usage: Custom configurations and interceptors
Now that you have the basics working, explore the detailed documentation:
- 💾 Storage Service - Complete storage guide with all implementations
- 🌐 Network Service - Advanced networking with interceptors and tokens
- 🔐 Token Management - Secure authentication handling
- 💡 Complete Examples - Real-world usage patterns
- 🏗️ Architecture Overview - System design and patterns
- ⚙️ Configuration Guide - Advanced setup options
- 🏆 Best Practices - Recommended patterns and security
- 📖 Documentation: Browse the docs directory for detailed guides
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions