Skip to content

Latest commit

 

History

History
147 lines (115 loc) · 4.15 KB

File metadata and controls

147 lines (115 loc) · 4.15 KB

🚀 Quick Start Guide

Get up and running with Flutter Infra in minutes!

📦 Installation

Add to your pubspec.yaml:

dependencies:
  flutter_infra: ^0.0.1

💾 Storage Quick Start

Basic Storage Operations

import '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());
}

Typed Extensions

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');

🌐 Network Quick Start

Basic Network Operations

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'});

With Authentication

// 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');

🔧 Basic Configuration

Storage Configuration

final storageService = await StorageService.create(
  config: StorageConfig(
    enableLogging: true,
    enableCache: true,
    encryptionKey: 'your-encryption-key',
  ),
);

Network Configuration

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',
    },
  ),
);

📱 Example App

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

📚 Next Steps

Now that you have the basics working, explore the detailed documentation:

🤝 Need Help?