Skip to content

A comprehensive Flutter scaffolding framework designed to accelerate development with a clean, modular architecture and powerful built-in services.

Notifications You must be signed in to change notification settings

f361600134/cat-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cat Framework

English | δΈ­ζ–‡

A comprehensive Flutter scaffolding framework designed to accelerate development with a clean, modular architecture and powerful built-in services. cat-framework.gif img.png

πŸš€ Features

Core Framework

  • Modular Architecture: Clean separation of concerns with organized module structure
  • Lifecycle Management: Built-in page lifecycle handling with caching support
  • Dependency Injection: Integrated with GetX for efficient service management
  • Responsive Design: Adaptive UI components for mobile, tablet, and desktop

Built-in Services

🌐 Network Layer

  • Protocol Adapter: Type-safe HTTP client with plugin architecture
  • Multiple HTTP Methods: Support for GET, POST, PUT, DELETE requests
  • Plugin System: Extensible with logging, caching, retry, and loading plugins
  • Error Handling: Comprehensive error management with automatic retry logic

πŸ’Ύ Storage System

  • Type-safe Storage: Generic repositories for different data types
  • Multiple Storage Types: Single object, list, and key-value storage repositories
  • JSON Serialization: Automatic serialization/deserialization support
  • Storage Management: Centralized storage container management

🎨 Theme System

  • Dynamic Theming: Runtime theme switching support
  • Multiple Themes: Light, dark, and system-follow modes
  • Customizable: Easy theme configuration and extension

🌍 Internationalization

  • Multi-language Support: Built-in i18n with easy language switching
  • Dynamic Translation: Runtime language changing without restart
  • Extensible: Simple addition of new languages and translations

⚑ Async Task Management

  • Polling Service: Background task execution with configurable intervals
  • Retry Logic: Automatic retry with exponential backoff
  • Task Lifecycle: Complete task management from creation to completion

πŸ“± UI Components

  • Notification System: Beautiful, customizable in-app notifications
  • Responsive Navigation: Adaptive navigation for different screen sizes
  • Page Management: Advanced page caching and lifecycle management

πŸ”§ Configuration Management

  • Local & Remote Config: Support for both local and remote configuration
  • Type Safety: Strongly typed configuration with validation
  • Environment Support: Multiple environment configurations

πŸ“‘ Event System

  • Event Bus: Decoupled communication between modules
  • Type-safe Events: Strongly typed event system
  • Subscription Management: Automatic subscription lifecycle management

πŸ“± Supported Platforms

  • βœ… Android - Full support with native optimizations
  • βœ… iOS - Complete iOS integration
  • βœ… Web - Progressive web app capabilities
  • βœ… macOS - Native desktop experience
  • βœ… Windows - Windows desktop application
  • βœ… Linux - Linux desktop support

πŸ›  Technology Stack

  • State Management: GetX 4.7.2
  • Storage: get_storage 2.1.1
  • Network: dio 5.7.0, http 1.2.2
  • Responsive UI: responsive_framework 1.5.1
  • Navigation: sidebarx 0.17.1
  • Utilities: intl, uuid, crypto, logger

πŸš€ Quick Start

Prerequisites

  • Flutter SDK 3.27.1 or higher
  • Dart SDK 3.0.0 or higher

Installation

  1. Clone the repository
git clone <repository-url>
cd cat-zson-pro
  1. Install dependencies
flutter pub get
  1. Run the application
flutter run

Basic Usage

1. Initialize the Framework

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  // Initialize Cat Framework with plugins
  await CatFramework.instance.initialize(
    config: const CatFrameworkConfig(
      appName: 'My App',
      supportedLocales: [
        Locale('en', 'us'),
        Locale('zh', 'cn'),
      ],
    ),
    networkPlugins: [
      LoggingPlugin(enableDetailLog: true),
      CachePlugin(),
      RetryPlugin(maxRetries: 3),
    ],
  );

  runApp(const MyApp());
}

2. Create Your App

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CatFramework.instance.createApp(
      title: 'My Cat Framework App',
      home: const HomePage(),
      pages: AppPages.routes,
    );
  }
}

3. Use Framework Services

// Network requests
final response = await Cat.network?.request(MyApiRequest());

// Storage operations
final storage = Cat.storage.createListRepository<User>(
  containerName: 'users',
  key: 'user_list',
);

// Event bus
Cat.events.fire(DataRefreshEvent(dataType: 'users'));

// Notifications
Cat.notify.showSuccess(message: 'Operation completed!');

// Theme switching
Cat.theme?.enableDarkMode();

// Language switching
Cat.i18n?.changeLocale('zh', 'cn');

πŸ“ Project Structure

lib/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ core/                 # Core framework components
β”‚   β”‚   β”œβ”€β”€ framework/        # Main framework classes
β”‚   β”‚   β”œβ”€β”€ network/          # Network layer & protocol adapter
β”‚   β”‚   β”œβ”€β”€ storage/          # Storage repositories
β”‚   β”‚   β”œβ”€β”€ async/            # Async task management
β”‚   β”‚   β”œβ”€β”€ event/            # Event bus system
β”‚   β”‚   β”œβ”€β”€ theme/            # Theme management
β”‚   β”‚   β”œβ”€β”€ i18n/             # Internationalization
β”‚   β”‚   β”œβ”€β”€ config/           # Configuration management
β”‚   β”‚   └── ui/               # UI services & components
β”‚   β”œβ”€β”€ modules/              # Feature modules
β”‚   β”‚   β”œβ”€β”€ home/             # Home module
β”‚   β”‚   β”œβ”€β”€ auth/             # Authentication module
β”‚   β”‚   β”œβ”€β”€ navigation/       # Navigation module
β”‚   β”‚   └── settings/         # Settings module
β”‚   β”œβ”€β”€ routes/               # Route definitions
β”‚   └── utils/                # Utility functions
β”œβ”€β”€ assets/                   # Asset files
└── main.dart                 # Application entry point

πŸ”§ Configuration

App Configuration

Create assets/config/app_config.json:

{
  "debug": true,
  "appName": "Cat Framework",
  "version": "1.0.0",
  "apiBaseUrl": "https://api.example.com",
  "timeout": 30,
  "environment": "development",
  "features": {
    "enableLogging": true,
    "enableCrashReporting": false,
    "enableAnalytics": false
  },
  "ui": {
    "defaultTheme": "light",
    "animationDuration": 300
  }
}

Framework Configuration

const config = CatFrameworkConfig(
  appName: 'My App',
  supportedLocales: [
    Locale('en', 'us'),
    Locale('zh', 'cn'),
    Locale('es', 'es'),
  ],
  fallbackLocale: Locale('en', 'us'),
  defaultStorageContainer: 'my_app_storage',
);

πŸ“š Advanced Usage

Custom Network Protocols

class UserListRequest extends IProtocolReq<List<User>> {
  @override
  String get url => '/api/users';
  
  @override
  HttpMethod get method => HttpMethod.get;
  
  @override
  Map<String, dynamic> toJson() => {};
  
  @override
  ApiResponse<List<User>> decode(dynamic data) {
    return ApiResponse.fromJson(
      data,
      (json) => (json as List).map((e) => User.fromJson(e)).toList(),
    );
  }
}

Custom Storage Repositories

class UserRepository {
  final storage = Cat.storage.createListRepository<User>(
    containerName: 'users',
    key: 'user_data',
  );
  
  List<User> getAllUsers() {
    return storage.readAll(fromJson: User.fromJson);
  }
  
  void saveUser(User user) {
    storage.add(
      item: user,
      toJson: (user) => user.toJson(),
      fromJson: User.fromJson,
    );
  }
}

Custom Events

class UserLoginEvent extends AppEvent {
  final String userId;
  UserLoginEvent(this.userId) : super('user_login');
}

// Subscribe to events
Cat.events.on<UserLoginEvent>((event) {
  print('User logged in: ${event.userId}');
});

// Fire events
Cat.events.fire(UserLoginEvent('user_123'));

πŸ§ͺ Testing

Running Tests

# Run all tests
flutter test

# Run tests with coverage
flutter test --coverage

# Run integration tests
flutter drive --target=test_driver/app.dart

Example Test

import 'package:flutter_test/flutter_test.dart';
import 'package:cat_zson_pro/app/core/framework/cat_framework.dart';

void main() {
  group('Cat Framework Tests', () {
    test('Framework initialization', () async {
      await CatFramework.instance.initialize();
      expect(CatFramework.instance.isInitialized, isTrue);
    });
  });
}

πŸ“¦ Building for Production

Android

flutter build apk --release
flutter build appbundle --release

iOS

flutter build ios --release

Web

flutter build web --release

Desktop

flutter build windows --release
flutter build macos --release
flutter build linux --release

Development Setup

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for your changes
  5. Ensure all tests pass
  6. Submit a pull request

Made with ❀️ by the Cat Framework Team

About

A comprehensive Flutter scaffolding framework designed to accelerate development with a clean, modular architecture and powerful built-in services.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published