Commit facdc92b authored by Tim Smart's avatar Tim Smart

2.1.0

parent 2f5bab1d
## 2.1.0
- Update for `provider` v4
## 2.0.0
- Update for `bloc_stream` 2.x
......
# Defines a default set of lint rules enforced for
# projects at Google. For details and rationale,
# see https://github.com/dart-lang/pedantic#enabled-lints.
include: package:pedantic/analysis_options.yaml
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
......
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
import 'package:provider/single_child_widget.dart';
import 'package:bloc_stream/bloc_stream.dart';
mixin BlocStreamProviderSingleChildWidget on SingleChildWidget {}
class BlocStreamProvider<T extends BlocStream<dynamic>>
extends ValueDelegateWidget<T> implements SingleChildCloneableWidget {
extends SingleChildStatelessWidget
with BlocStreamProviderSingleChildWidget {
final Widget child;
final bool lazy;
final Dispose<T> _dispose;
final Create<T> _create;
BlocStreamProvider({
Key key,
@required ValueBuilder<T> create,
@required Create<T> create,
Widget child,
bool lazy,
}) : this._(
key: key,
delegate: BuilderStateDelegate<T>(
create,
dispose: (_, stream) => stream?.close(),
),
create: create,
dispose: (_, bloc) => bloc?.close(),
child: child,
lazy: lazy,
);
BlocStreamProvider.value({
......@@ -25,45 +36,48 @@ class BlocStreamProvider<T extends BlocStream<dynamic>>
Widget child,
}) : this._(
key: key,
delegate: SingleValueDelegate<T>(value),
create: (_) => value,
child: child,
);
BlocStreamProvider._({
Key key,
@required ValueStateDelegate<T> delegate,
@required Create<T> create,
Dispose<T> dispose,
this.child,
}) : super(key: key, delegate: delegate);
this.lazy,
}) : _create = create,
_dispose = dispose,
super(key: key, child: child);
static T of<T extends BlocStream<dynamic>>(BuildContext context) {
try {
return Provider.of<T>(context, listen: false);
} on Object catch (_) {
} on ProviderNotFoundException catch (_) {
throw FlutterError(
'''
"""
BlocStreamProvider.of() called with a context that does not contain a BlocStream of type $T.
No ancestor could be found starting from the context that was passed to BlocStreamProvider.of<$T>().
This can happen if the context you used comes from a widget above the BlocStreamProvider.
The context used was: $context
''',
""",
);
}
}
@override
Widget build(BuildContext context) {
Widget buildWithChild(BuildContext context, Widget child) {
return InheritedProvider<T>(
value: delegate.value,
create: _create,
dispose: _dispose,
child: child,
lazy: lazy,
);
}
}
@override
BlocStreamProvider<T> cloneWithChild(Widget child) {
return BlocStreamProvider<T>._(
key: key,
delegate: delegate,
child: child,
);
}
extension BlocStreamProviderExtension on BuildContext {
B bloc<B extends BlocStream>() => BlocStreamProvider.of<B>(this);
}
name: flutter_bloc_stream
description: Helper package for using bloc_stream with Flutter. Includes BlocStreamProvider and BlocStreamBuilder.
version: 2.0.0
version: 2.1.0
homepage: https://gitlab.com/arisechurch/bloc_stream
environment:
sdk: ">=2.5.0 <3.0.0"
sdk: ">=2.6.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
bloc_stream: ">= 2.0.0 < 3.0.0"
provider: ">= 3.0.0 < 4.0.0"
provider: ">= 4.0.0 < 5.0.0"
dev_dependencies:
pedantic: ^1.8.0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment