diff --git a/android/app/build.gradle b/android/app/build.gradle index 5530bd7..008e1ff 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -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' diff --git a/android/gradle.properties b/android/gradle.properties index 8bd86f6..7be3d8b 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1 +1,2 @@ org.gradle.jvmargs=-Xmx1536M +android.enableR8=true diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh new file mode 100644 index 0000000..59af148 --- /dev/null +++ b/ios/Flutter/flutter_export_environment.sh @@ -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" diff --git a/lib/counter_bloc.dart b/lib/counter_bloc.dart index 2a69564..b519bbd 100644 --- a/lib/counter_bloc.dart +++ b/lib/counter_bloc.dart @@ -4,11 +4,11 @@ import 'package:bloc_library_tut/counter_state.dart'; class CounterBloc extends Bloc { void onIncrement() { - dispatch(IncrementEvent()); + add(IncrementEvent()); } void onDecrement() { - dispatch(DecrementEvent()); + add(DecrementEvent()); } @override @@ -16,7 +16,7 @@ class CounterBloc extends Bloc { @override Stream 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) { diff --git a/lib/main.dart b/lib/main.dart index 5b48ea2..acf347e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -33,16 +33,21 @@ class _MyHomePageState extends State { @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 { diff --git a/pubspec.yaml b/pubspec.yaml index 3bf45c1..8c88731 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.