opticore 2.1.2 copy "opticore: ^2.1.2" to clipboard
opticore: ^2.1.2 copied to clipboard

OptiCore is a lightweight micro-framework for Flutter that simplifies and optimizes your app development

example/README.md

OptiCore Module Structure 🚀 #

This document outlines the OptiCore module structure, designed for scalability, maintainability, and efficiency. The architecture ensures a clean separation of concerns, making development seamless.

📂 Folder Structure #

Each module follows this structured hierarchy:

lib/
  module/
    <ModuleName>/
      📦 bloc/              # Business logic layer (BLoC)
        ├── <module_name>_bloc.dart
      ⚡ event/              # Events triggering BLoC updates
        ├── <module_name>_event.dart
      📊 state/              # UI state definitions
        ├── <module_name>_state.dart
      🖥️ screen/             # UI components (Widgets)
        ├── <module_name>_screen.dart
      🔗 import/             # Centralized module imports
        ├── <module_name>_import.dart
      🏭 factory/            # State factory management
        ├── <module_name>_state_factory.dart

✨ Example: ExampleModule #

lib/
  module/
    ExampleModule/
      📦 bloc/
        ├── example_module_bloc.dart
      ⚡ event/
        ├── example_module_event.dart
      📊 state/
        ├── example_module_state.dart
      🖥️ screen/
        ├── example_module_screen.dart
      🔗 import/
        ├── example_module_import.dart
      🏭 factory/
        ├── example_module_state_factory.dart

🔍 File Overview #

🏗️ BLoC (example_module_bloc.dart) #

Handles the business logic and state transitions.

part of '../import/example_module_import.dart';

class ExampleModuleBloc extends BaseBloc {
  ExampleModuleBloc()
      : super(
          ExampleModuleStateFactory(),
          initialState: ExampleModuleInitialState(),
        );

  @override
  void onDispose() {}
}

Event (example_module_event.dart) #

Defines events that trigger state changes.

part of '../import/example_module_import.dart';

class ExampleModuleInitialEvent extends BaseEvent {}

📊 State (example_module_state.dart) #

Defines the UI state.

part of '../import/example_module_import.dart';

class ExampleModuleInitialState extends RenderDataState {
  ExampleModuleInitialState() : super(null);
}

🖥️ Screen (example_module_screen.dart) #

Handles the UI and interacts with the BLoC.

part of '../import/example_module_import.dart';

class ExampleModuleScreen extends StatefulWidget {
  final ExampleModuleBloc bloc;

  const ExampleModuleScreen({super.key, required this.bloc});

  @override
  ExampleModuleScreenState createState() => ExampleModuleScreenState(bloc);
}

class ExampleModuleScreenState
    extends BaseScreen<ExampleModuleBloc, ExampleModuleScreen, dynamic> {
  ExampleModuleScreenState(super.bloc);

  @override
  Widget buildWidget(BuildContext context, RenderDataState state) {
    return Container();
  }

  @override
  void listenToState(BuildContext context, BaseState state) {}
}

🔗 Import (example_module_import.dart) #

Manages centralized imports.

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

part '../bloc/example_module_bloc.dart';
part '../event/example_module_event.dart';
part '../screen/example_module_screen.dart';
part '../state/example_module_state.dart';
part '../factory/example_module_state_factory.dart';

🏭 State Factory (example_module_state_factory.dart) #

Creates and manages different states dynamically.

part of '../import/example_module_import.dart';

class ExampleModuleStateFactory extends BaseFactory {
  @override
  BaseState getState<M>(M data) {
    return DefaultState();
  }
}

🎯 Key Benefits #

Modular & Scalable – Ensures long-term maintainability
Separation of Concerns – Organized into logical units
Optimized for BLoC – Structured for predictable state management

Start building robust OptiCore modules with this scalable structure today! 🚀

23
likes
160
points
410
downloads

Publisher

unverified uploader

Weekly Downloads

OptiCore is a lightweight micro-framework for Flutter that simplifies and optimizes your app development

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

bot_toast, cached_network_image, connectivity_plus, dio, dio_smart_retry, equatable, flutter, flutter_bloc, flutter_svg, font_awesome_flutter, internet_connection_checker_plus, lottie, modal_bottom_sheet, talker, talker_dio_logger

More

Packages that depend on opticore