Skip to content

Commit

Permalink
flutter_bloc v0.2.1 + bloc v0.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed Oct 24, 2018
1 parent c0c9ab0 commit c816978
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 23 deletions.
17 changes: 15 additions & 2 deletions examples/flutter_login/lib/login/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_login/authentication/authentication.dart';
import 'package:flutter_login/login/login.dart';

class LoginPage extends StatelessWidget {
class LoginPage extends StatefulWidget {
@override
State<LoginPage> createState() => LoginPageState();
}

class LoginPageState extends State<LoginPage> {
final LoginBloc _loginBloc = LoginBloc();

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -14,8 +21,14 @@ class LoginPage extends StatelessWidget {
),
body: LoginForm(
authBloc: BlocProvider.of<AuthenticationBloc>(context),
loginBloc: BlocProvider.of<LoginBloc>(context),
loginBloc: _loginBloc,
),
);
}

@override
void dispose() {
_loginBloc.dispose();
super.dispose();
}
}
17 changes: 3 additions & 14 deletions examples/flutter_login/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@ import 'package:flutter_login/login/login.dart';
import 'package:flutter_login/home/home.dart';

void main() {
final loginBloc = LoginBloc();
final authenticationBloc = AuthenticationBloc();

runApp(App(
loginBloc: loginBloc,
authenticationBloc: authenticationBloc,
));
}

class App extends StatelessWidget {
final LoginBloc loginBloc;
final AuthenticationBloc authenticationBloc;

const App({
Key key,
@required this.loginBloc,
@required this.authenticationBloc,
}) : super(key: key);

Expand All @@ -48,7 +44,7 @@ class App extends StatelessWidget {
if (authState.isAuthenticated) {
_widgets.add(HomePage());
} else {
_widgets.add(_loginPage());
_widgets.add(LoginPage());
}

if (authState.isInitializing) {
Expand All @@ -66,19 +62,12 @@ class App extends StatelessWidget {
);
}

Widget _loginPage() {
return BlocProvider<LoginBloc>(
bloc: loginBloc,
child: LoginPage(),
);
}

Widget _loadingIndicator() {
return Stack(
children: [
children: <Widget>[
Opacity(
opacity: 0.3,
child: const ModalBarrier(dismissible: false, color: Colors.grey),
child: ModalBarrier(dismissible: false, color: Colors.grey),
),
Center(
child: CircularProgressIndicator(),
Expand Down
4 changes: 4 additions & 0 deletions packages/bloc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,7 @@ Moved Flutter Widgets to flutter_bloc package
# 0.5.1

Minor Updates to Documentation

# 0.5.2

Additional minor Updates to Documentation.
3 changes: 2 additions & 1 deletion packages/bloc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![codecov](https://codecov.io/gh/felangel/Bloc/branch/master/graph/badge.svg)](https://codecov.io/gh/felangel/bloc)
[![Pub](https://img.shields.io/pub/v/bloc.svg)](https://pub.dartlang.org/packages/bloc)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Gitter](https://img.shields.io/badge/gitter-bloc-blue.svg)](https://gitter.im/bloc_package/Lobby)
[![Gitter](https://img.shields.io/badge/gitter-bloc-yellow.svg)](https://gitter.im/bloc_package/Lobby)

---

Expand Down Expand Up @@ -162,6 +162,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
## Examples

- [Simple Counter Example](https://github.com/felangel/Bloc/tree/master/packages/bloc/example) - an example of how to create a `CounterBloc` (pure dart)
- [Login Flow Example](https://github.com/felangel/Bloc/tree/master/examples/flutter_login) - an example of how to use the `bloc` and `flutter_bloc` packages to implement a Login Flow.

### Contributors

Expand Down
2 changes: 1 addition & 1 deletion packages/bloc/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bloc
description: The goal of this package is to make it easy to implement the BLoC Design Pattern (Business Logic Component).
version: 0.5.1
version: 0.5.2
author: felix.angelov <felangelov@gmail.com>
homepage: https://github.com/felangel/bloc/tree/master/packages/bloc

Expand Down
6 changes: 5 additions & 1 deletion packages/flutter_bloc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ Updates to `BlocBuilder` and `BlocProvider`

- `BlocBuilder` does not automatically dispose a `Bloc`. Developers are now responsible for determining when to call `Bloc.dispose()`
- `BlocProvider` support for `of(context)` with generics
- Support for multiple nested `BlocProviders` with different Bloc Types.
- Support for multiple nested `BlocProviders` with different Bloc Types.

# 0.2.1

Minor Updates to Documentation
4 changes: 2 additions & 2 deletions packages/flutter_bloc/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MyAppState extends State<MyApp> {
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: BlocProvider(
home: BlocProvider<CounterBloc>(
bloc: _counterBloc,
child: CounterPage(),
),
Expand All @@ -30,7 +30,7 @@ class MyAppState extends State<MyApp> {
class CounterPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final CounterBloc _counterBloc = BlocProvider.of(context) as CounterBloc;
final CounterBloc _counterBloc = BlocProvider.of<CounterBloc>(context);

return Scaffold(
appBar: AppBar(title: Text('Counter')),
Expand Down
5 changes: 4 additions & 1 deletion packages/flutter_bloc/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ environment:

dependencies:
flutter_bloc:
path: ../
path: ../

flutter:
uses-material-design: true
2 changes: 1 addition & 1 deletion packages/flutter_bloc/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_bloc
description: Flutter Widgets that make it easy to implement the BLoC Design Pattern (Business Logic Component). Built to be used with the bloc package.
version: 0.2.0
version: 0.2.1
author: felix.angelov <felangelov@gmail.com>
homepage: https://github.com/felangel/bloc/tree/master/packages/flutter_bloc

Expand Down

0 comments on commit c816978

Please sign in to comment.