Skip to content

Commit

Permalink
feat: update AuthProvider to be used with MultiProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
iamchathu committed May 18, 2022
1 parent 717aaba commit 9fc37be
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.1.2

* Update AuthProvider to be used with MultiProvider.

### 0.1.1

* Make child property optional in AuthProvider.
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.0"
version: "0.1.1"
flutter_lints:
dependency: "direct dev"
description:
Expand Down
12 changes: 10 additions & 2 deletions lib/src/auth_provider.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_auth_provider/flutter_auth_provider.dart';
import 'package:provider/provider.dart';
import 'package:provider/single_child_widget.dart';

class AuthProvider<U> extends StatelessWidget {
mixin AuthProviderSingleChildWidget on SingleChildWidget {}

class AuthProvider<U> extends SingleChildStatelessWidget
with AuthProviderSingleChildWidget {
final AuthStore<U> store;
final Widget? child;

Expand All @@ -13,7 +17,11 @@ class AuthProvider<U> extends StatelessWidget {
}) : super(key: key);

@override
Widget build(BuildContext context) {
Widget buildWithChild(BuildContext context, Widget? child) {
assert(
child != null,
'$runtimeType used outside of MultiProvider must specify a child',
);
return ChangeNotifierProvider(
create: (_) => AuthManager<U>(store)..initialize(),
child: child,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_auth_provider
description: Simple, customizable authentication manager for Flutter
version: 0.1.1
version: 0.1.2
homepage: https://github.com/iamchathu/flutter_auth_provider

environment:
Expand Down

0 comments on commit 9fc37be

Please sign in to comment.