opticore 2.1.6 copy "opticore: ^2.1.6" to clipboard
opticore: ^2.1.6 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
150
points
274
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

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

auto_validate, 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