Skip to content

Commit

Permalink
Add readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertOdrowaz committed Sep 1, 2021
1 parent 7960166 commit 505d7ff
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 30 deletions.
28 changes: 18 additions & 10 deletions packages/bloc_dispose_scope/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# flutter_dispose_scope
# BlocDisposeScope

A new Flutter package project.
BlocDisposeScope adds support for bloc related types to [dispose_scope](https://pub.dev/packages/dispose_scope) package.

## Getting Started
## Usage

This project is a starting point for a Dart
[package](https://flutter.dev/developing-packages/),
a library module containing code that can be shared easily across
multiple Flutter or Dart projects.
```dart
import 'package:bloc_dispose_scope/bloc_dispose_scope.dart';
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
class MainCubit extends Cubit<String> with BlocBaseDisposeScopeMixin {
MainCubit(this._dependencyCubit) : super('') {
// StreamSubscription will be cancelled when MainCubit is closed
_dependencyCubit.stream
.listen(_onDependencyCubitStateChanged)
.disposed(scope);
}
final DependencyCubit _dependencyCubit;
void _onDependencyCubitStateChanged(String dependencyState) {}
}
```
32 changes: 22 additions & 10 deletions packages/dispose_scope/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# dispose_scope
# DisposeScope

A new Flutter package project.
DisposeScope reduces the amount of boilerplate related to disposing/canceling/closing objects when no longer needed.
The `DisposeScope` class stores references to appropriate `dispose`/`close`/`cancel` methods and calls them when the scope is disposed.

## Getting Started
This package can be used by itself however it's mainly intended as base for [flutter_dispose_scope](https://pub.dev/packages/flutter_dispose_scope) and [bloc_dispose_scope](https://pub.dev/packages/bloc_dispose_scope) packages.

This project is a starting point for a Dart
[package](https://flutter.dev/developing-packages/),
a library module containing code that can be shared easily across
multiple Flutter or Dart projects.
## Usage

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
```dart
import 'package:dispose_scope/dispose_scope.dart';
final disposeScope = DisposeScope();
// StreamSubscription will be cancelled when disposeScope is disposed
const Stream.empty().listen((event) {}).disposed(disposeScope);
// Timer will be cancelled when disposeScope is disposed
Timer(Duration.zero, () {}).disposed(disposeScope);
disposeScope.dispose();
```

## Supported types

This package contains extension methods for dart standard library classes requiring clean up. For additional extension methods checkout [flutter_dispose_scope](https://pub.dev/packages/flutter_dispose_scope) and [bloc_dispose_scope](https://pub.dev/packages/bloc_dispose_scope).
42 changes: 32 additions & 10 deletions packages/flutter_dispose_scope/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
# flutter_dispose_scope
# BlocDisposeScope

A new Flutter package project.
BlocDisposeScope adds support for flutter related types to [dispose_scope](https://pub.dev/packages/dispose_scope) package.

## Getting Started
## Usage

This project is a starting point for a Dart
[package](https://flutter.dev/developing-packages/),
a library module containing code that can be shared easily across
multiple Flutter or Dart projects.
```dart
import 'package:flutter_dispose_scope/flutter_dispose_scope.dart';
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
class App extends StatefulWidget {
const App({Key? key}) : super(key: key);
@override
_AppState createState() => _AppState();
}
class _AppState extends State<App> with StateDisposeScopeMixin {
@override
void initState() {
super.initState();
// StreamSubscription will be cancelled when widget is disposed
const Stream.empty().listen((event) {}).disposed(scope);
// Timer will be cancelled when widget is disposed
Timer(Duration.zero, () {}).disposed(scope);
}
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: SizedBox(),
);
}
}
```

0 comments on commit 505d7ff

Please sign in to comment.