disposer

Creator: coderz1093

Last updated:

0 purchases

disposer Image
disposer Images

Languages

Categories

Add to Cart

Description:

disposer

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();
}
}

copied to clipboard
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;
}

copied to clipboard
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
copied to clipboard
Usage:
disposer --name NewFeature --output lib/src/features
copied to clipboard
Second approach #
Add disposer like dependency to your project
dependencies:
disposer: ^0.0.7
copied to clipboard
Usage:
flutter pub run disposer --name NewFeature --output lib/src/features
copied to clipboard
Feature naming convention:
-n example
--name example
-n Example
--name Example
-n ExampleFeature
--name ExampleFeature
copied to clipboard
Output parameter is optional. Default path is: lib/features.
Example:
-o lib/src/features
--output lib/src/features
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.