Welcome to the Disposable package

It's a simple interface to manage all instances that needs to been disposed.

Example

import 'dart:async';
import 'package:disposer/disposer.dart';

class DataSource with Disposable {
    final streamController = StreamController.broadcast();
    
    @override
    void dispose() {
        streamController.close();
    }
}

Multilevel dependencies example:

import 'dart:async';
import 'package:disposer/disposer.dart';


void main() {
  final LocalDataSource localDataSource = LocalDataSource();
  final RemoteDataSource remoteDataSource = RemoteDataSource();
  final DataRepository dataRepository = DataRepository(
    localDataSource: localDataSource,
    remoteDataSource: remoteDataSource,
  );
  final DataUsecase dataUsecase = DataUsecase(repository: dataRepository);
  dataUsecase.dispose();

  // Output:
  /*
    [log] LocalDataSource Disposed
    [log] RemoteDataSource Disposed
    [log] DataRepository Disposed
    [log] DataUsecase Disposed
  */
}

class LocalDataSource with Disposable {
  final streamController = StreamController.broadcast();

  @override
  void dispose() {
    streamController.close();
    super.dispose();
  }
}

class RemoteDataSource with Disposable {
  final streamController = StreamController.broadcast();

  @override
  void dispose() {
    streamController.close();
    super.dispose();
  }
}

class DataRepository with Disposable {
  DataRepository({
    required this.localDataSource,
    required this.remoteDataSource,
  });

  @override
  List<Disposable> get disposables => [
        localDataSource,
        remoteDataSource,
      ];

  final LocalDataSource localDataSource;
  final RemoteDataSource remoteDataSource;
}

class DataUsecase with Disposable {
  DataUsecase({
    required this.repository,
  });

  @override
  List<Disposable> get disposables => [
        repository,
      ];

  final DataRepository repository;
}

Feature generator

Future generator creates new clean architecture feature:

Folders structure:

Start working with future generator

First approach

Activate the global pub package. With this approach, you can use features generator globally

Activate:

    dart pub global activate disposer

Usage:

    disposer --name NewFeature --output lib/src/features

Second approach

Add disposer like dependency to your project

  dependencies:
    disposer: ^0.0.7

Usage:

  flutter pub run disposer --name NewFeature --output lib/src/features

Feature naming convention:

    -n example
    --name example
    -n Example
    --name Example
    -n ExampleFeature
    --name ExampleFeature

Output parameter is optional. Default path is: lib/features.

Example:

    -o lib/src/features
    --output lib/src/features

Libraries

constants
disposer
feature_builder
helper
template_builder
template_data_model
template_data_source
template_data_source_interface
template_entitie
template_page
template_repository
template_repository
template_router
template_router_interface
template_usecase
template_usecase_interface
template_view_model
template_view_model_interface
template_view_state
template_widget