Skip to content

Commit

Permalink
feat(hydrated_bloc)!: null safety (#2117)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed Jan 31, 2021
1 parent 12d0bc1 commit eaee9a5
Show file tree
Hide file tree
Showing 66 changed files with 1,303 additions and 1,480 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/hydrated_bloc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ name: hydrated_bloc

on:
push:
branches:
- master
paths:
- ".github/workflows/hydrated_bloc.yaml"
- "packages/hydrated_bloc/**"
- ".github/workflows/hydrated_bloc.yaml"

pull_request:
branches:
- master
paths:
- ".github/workflows/hydrated_bloc.yaml"
- "packages/hydrated_bloc/**"
- ".github/workflows/hydrated_bloc.yaml"

jobs:
build:
Expand All @@ -24,15 +20,21 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: subosito/[email protected]
with:
channel: beta
- name: Install Dependencies
run: flutter packages get
run: flutter pub get
- name: Format
run: flutter format --set-exit-if-changed lib test example
- name: Analyze
run: flutter analyze lib test example
- name: Run tests
run: flutter test -j 1 --no-pub --coverage --test-randomize-ordering-seed random
- name: Check Code Coverage
uses: ChicagoFlutter/lcov-cop@v1.0.0
uses: VeryGoodOpenSource/very_good_coverage@v1.1.1
with:
path: packages/hydrated_bloc/coverage/lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
9 changes: 9 additions & 0 deletions packages/hydrated_bloc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 7.0.0-nullsafety.0

- **BREAKING**: opt into null safety
- **BREAKING**: refactor: upgrade to `bloc ^7.0.0-nullsafety.1`
- **BREAKING**: refactor: remove `flutter` dependency
- **BREAKING**: `storageDirectory` is required when calling `HydratedStorage.build`
- **BREAKING**: `HydratedCubit.storage` is removed in favor of `HydratedBloc.storage`
- feat!: upgrade Dart SDK constraints to `>=2.12.0-0 <3.0.0`

# 6.1.0

- feat: export `package:bloc/bloc.dart`
Expand Down
8 changes: 4 additions & 4 deletions packages/hydrated_bloc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ Our top sponsors are shown below! [[Become a Sponsor](https://github.com/sponsor
```dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
HydratedBloc.storage = await HydratedStorage.build();
HydratedBloc.storage = await HydratedStorage.build(
storageDirectory: await getTemporaryDirectory(),
);
runApp(App());
}
```
Expand Down Expand Up @@ -121,9 +123,7 @@ class CounterCubit extends Cubit<int> with HydratedMixin {

## Custom Storage Directory

By default, all data is written to [temporary storage](https://github.com/flutter/plugins/blob/61c39d1e79e8f36030162a5f85fb491c65f4e51c/packages/path_provider/lib/path_provider.dart#L24) which means it can be wiped by the operating system at any point in time.

An optional `storageDirectory` can be provided to override the default temporary storage directory:
Any `storageDirectory` can be used when creating an instance of `HydratedStorage`:

```dart
HydratedBloc.storage = await HydratedStorage.build(
Expand Down
3 changes: 3 additions & 0 deletions packages/hydrated_bloc/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ analyzer:
implicit-dynamic: false
errors:
close_sinks: ignore
exclude:
- test/cubits/freezed_cubit.freezed.dart
- test/cubits/freezed_cubit.g.dart

linter:
rules:
Expand Down
4 changes: 4 additions & 0 deletions packages/hydrated_bloc/example/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ gradle-wrapper.jar
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
14 changes: 6 additions & 8 deletions packages/hydrated_bloc/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ if (flutterVersionName == null) {
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 30

lintOptions {
disable 'InvalidPackage'
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand All @@ -55,7 +55,5 @@ flutter {
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
<application
android:label="example"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
4 changes: 3 additions & 1 deletion packages/hydrated_bloc/example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/hydrated_bloc/example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
18 changes: 7 additions & 11 deletions packages/hydrated_bloc/example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
1 change: 1 addition & 0 deletions packages/hydrated_bloc/example/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
3 changes: 3 additions & 0 deletions packages/hydrated_bloc/example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe
flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

Expand Down
Loading

0 comments on commit eaee9a5

Please sign in to comment.