masterfabric_core 0.0.2 copy "masterfabric_core: ^0.0.2" to clipboard
masterfabric_core: ^0.0.2 copied to clipboard

Core utilities, base classes, and shared logic for the MasterFabric Flutter project.

masterfabric_core #

pub package License

A comprehensive Flutter package providing core utilities, base classes, and shared logic for building scalable Flutter applications. MasterFabric Core serves as the foundational layer for MasterFabric projects, offering a complete architecture with state management, navigation, dependency injection, and pre-built views.

Features #

πŸ—οΈ Architecture & State Management #

  • Base View Classes: BaseViewBloc, BaseViewCubit, BaseViewHydratedCubit for different state management needs
  • Master View System: Unified view management with MasterView, MasterViewCubit, and MasterViewHydratedCubit
  • State Persistence: Hydrated BLoC support for state persistence across app restarts
  • View Models: Base classes for business logic separation

🧭 Navigation & Routing #

  • GoRouter Integration: Pre-configured routing with AppRoutes
  • Route Management: Centralized route definitions and navigation helpers

🎨 Pre-built Views #

  • SplashView: App launch screen with loading logic
  • OnboardingView: User onboarding flow
  • AuthView: Authentication screen with Sign In/Sign Up tabs
  • AccountView: User account management screen
  • PermissionsView: Runtime permission request screens
  • ErrorHandlingView: Error display and recovery
  • LoadingView: Loading state views
  • EmptyView: Empty state views
  • InfoBottomSheetView: Information bottom sheets
  • ImageDetailView: Image detail viewer
  • SearchView: Search functionality interface

πŸ› οΈ Helper Utilities #

  • LocalStorageHelper: SharedPreferences wrapper for local storage
  • AuthStorageHelper: Authentication data persistence
  • PermissionHandlerHelper: Runtime permissions management
  • LocalNotificationHelper: Local push notifications
  • FileDownloadHelper: File downloads with progress tracking
  • DateTimeHelper: Date and time operations and formatting
  • UrlLauncherHelper: External URL and app launching
  • WebViewerHelper: HTML/WebView rendering utilities
  • ApplicationShareHelper: Content sharing functionality
  • DeviceInfoHelper: Device information retrieval
  • AssetConfigHelper: JSON config management from assets
  • GridHelper: Grid layout calculation utilities
  • SpacerHelper: UI spacing utilities
  • CommonLoggerHelper: Logging utilities

πŸ“ Layout System #

  • Grid: Responsive grid layout system
  • Spacer: Consistent spacing utilities

πŸ”Œ Dependency Injection #

  • Injectable Integration: Pre-configured dependency injection setup
  • GetIt Integration: Service locator pattern support

🌍 Localization #

  • Slang Integration: i18n support with Slang
  • Translation Support: English translation file structure

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  masterfabric_core: ^0.0.2

Then run:

flutter pub get

From Git (Development) #

For the latest development version, you can use:

dependencies:
  masterfabric_core:
    git:
      url: https://github.com/gurkanfikretgunak/masterfabric_core.git
      ref: dev  # or use a specific tag/commit

Then run:

flutter pub get

Quick Start #

1. Setup Your App with MasterApp #

import 'package:flutter/material.dart';
import 'package:masterfabric_core/masterfabric_core.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MasterApp(
      // Configure your app here
      title: 'My App',
      // Add your router configuration
    );
  }
}

2. Create a View with MasterView #

import 'package:masterfabric_core/masterfabric_core.dart';

class ProductsView extends MasterView<ProductsCubit, ProductsState> {
  ProductsView({super.key}) : super(currentView: MasterViewTypes.content);

  @override
  void initialContent(ProductsCubit cubit, BuildContext context) {
    cubit.loadProducts();
  }

  @override
  Widget viewContent(BuildContext context, ProductsCubit cubit, ProductsState state) {
    if (state.isLoading) {
      return LoadingView();
    }
    
    if (state.hasError) {
      return ErrorHandlingView(error: state.error);
    }
    
    return ListView.builder(
      itemCount: state.products.length,
      itemBuilder: (context, index) {
        return ProductItem(product: state.products[index]);
      },
    );
  }
}

3. Use Pre-built Views #

import 'package:masterfabric_core/masterfabric_core.dart';
import 'package:go_router/go_router.dart';

// In your router configuration
GoRoute(
  path: '/auth',
  builder: (context, state) => AuthView(
    goRoute: (path) => context.go(path),
    arguments: state.uri.queryParameters,
  ),
),

GoRoute(
  path: '/onboarding',
  builder: (context, state) => OnboardingView(
    config: onboardingConfig,
    goRoute: (path) => context.go(path),
    arguments: state.uri.queryParameters,
  ),
),

4. Use Helper Utilities #

import 'package:masterfabric_core/masterfabric_core.dart';

// Local Storage
final storage = LocalStorageHelper();
await storage.setString('key', 'value');
final value = await storage.getString('key');

// Permissions
final permissionHelper = PermissionHandlerHelper();
final granted = await permissionHelper.requestPermission(Permission.camera);

// Date Formatting
final formatted = DateTimeHelper.formatDate(DateTime.now(), 'yyyy-MM-dd');

// URL Launcher
await UrlLauncherHelper.launchUrl('https://example.com');

// Device Info
final deviceInfo = DeviceInfoHelper();
final platform = await deviceInfo.getPlatform();

Package Structure #

lib/
β”œβ”€β”€ masterfabric_core.dart          # Main library export
└── src/
    β”œβ”€β”€ base/                       # Base classes and architecture
    β”‚   β”œβ”€β”€ base_view_*.dart        # Base view classes
    β”‚   β”œβ”€β”€ master_view/            # Master view system
    β”‚   └── widgets/                # Base widgets
    β”œβ”€β”€ helper/                     # Utility helpers
    β”œβ”€β”€ views/                      # Pre-built views
    β”œβ”€β”€ models/                     # Data models
    β”œβ”€β”€ layout/                     # Layout utilities
    β”œβ”€β”€ resources/                  # Generated resources
    └── di/                         # Dependency injection

Requirements #

  • Dart SDK: ^3.9.2
  • Flutter: >=1.17.0

Dependencies #

Core Dependencies #

  • flutter_bloc: ^9.1.0 - State management
  • hydrated_bloc: ^10.1.1 - State persistence
  • go_router: ^15.1.1 - Navigation
  • injectable: ^2.7.1 - Dependency injection
  • slang: ^4.11.1 - Localization

See pubspec.yaml for complete dependency list #

Documentation #

For detailed documentation, see:

  • CHANGELOG.md - Version history and changes
  • doc/analysis.md - Architecture analysis

Package Information #

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

License #

This project is licensed under the GNU AGPL v3.0 License - see the LICENSE file for details.

Support #

For issues, questions, or contributions, please visit the GitHub repository.

Publishing #

This package is published on pub.flutter-io.cn. You can install it directly using:

flutter pub add masterfabric_core

Or add it manually to your pubspec.yaml:

dependencies:
  masterfabric_core: ^0.0.2

Published Package: This package is available on pub.flutter-io.cn. For the latest stable version, use the pub.flutter-io.cn installation method above.