Skip to content

Project updated to bloc ^4.0.0 and is working correctly #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 27
compileSdkVersion 28

lintOptions {
disable 'InvalidPackage'
Expand Down
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
15 changes: 15 additions & 0 deletions ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\src\flutter\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\Marcelo\usr\apps\flutter\flutter-bloc-library-tutorial"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=C:\src\flutter\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
6 changes: 3 additions & 3 deletions lib/counter_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import 'package:bloc_library_tut/counter_state.dart';

class CounterBloc extends Bloc<CounterEvent, CounterState> {
void onIncrement() {
dispatch(IncrementEvent());
add(IncrementEvent());
}

void onDecrement() {
dispatch(DecrementEvent());
add(DecrementEvent());
}

@override
CounterState get initialState => CounterState.initial();

@override
Stream<CounterState> mapEventToState(CounterEvent event) async* {
final _currentState = currentState;
final _currentState = state;
if (event is IncrementEvent) {
yield CounterState(counter: _currentState.counter + 1);
} else if (event is DecrementEvent) {
Expand Down
17 changes: 11 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,21 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return BlocProvider(
bloc: _counterBloc,
create: (BuildContext context) => _counterBloc,
child: CounterWidget(widget: widget),
);
}

@override
void dispose() {
_counterBloc.dispose();
super.dispose();
}
// @override
// void dispose() {
// _counterBloc.dispose();
// super.dispose();
// }

/*
* Since flutter_bloc 0.19.0
* BlocProvider will now handle automatically disposing of blocs for you
* */
}

class CounterWidget extends StatelessWidget {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_bloc: ^0.6.0
flutter_bloc: ^4.0.0

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down