Skip to content
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

Migrate project to Dart 3 #262

Open
wants to merge 6 commits into
base: main
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
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
.packages
.pub/
.dart_tool/
pubspec.lock
flutter_export_environment.sh

examples/all_plugins/pubspec.yaml

Podfile
Podfile.lock
Pods/
.symlinks/
**/Flutter/App.framework/
Expand Down Expand Up @@ -46,4 +43,6 @@ build/
.classpath
.settings
.last_build_id
.fvm/flutter_sdk

# FVM Version Cache
.fvm/
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 3.0.0-beta.5

- Migrate to Dart 3, update version constraints to require Flutter >=3.3.0 and SDK >=3.0.0
- Migrate Android project to AGP8, set target and compile SDK to 34
- Updated gitignore to keep lock files and Podfile in example app
- Updated analysis_options.yaml
- Cosmetic updates to example app
- Set iOS deployment target to iOS 14
- Set Android min SDK to 21

## 3.0.0-beta.4

- Restore compatibility with Android 12
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,18 @@ func registerPlugins(registry: FlutterPluginRegistry) {
- **Configure maximum number of concurrent tasks:** the plugin depends on `WorkManager` library and `WorkManager` depends on the number of available processor to configure the maximum number of tasks running at a moment. You can setup a fixed number for this configuration by adding following codes to your `AndroidManifest.xml`:

```xml
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
android:enabled="false"
android:exported="false" />
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:enabled="false"
android:exported="false"
tools:node="merge">
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:enabled="false"
android:exported="false"
android:value="androidx.startup" />
</provider>

<provider
android:name="com.bluechilli.flutteruploader.FlutterUploaderInitializer"
Expand Down
28 changes: 16 additions & 12 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:8.0.2'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should increase the agp plugin, I'd prefer to use the newest 8.5.0 if flutter supports it, if not the highest supported version would be great

}
}

Expand All @@ -22,16 +22,19 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 31
if (project.android.hasProperty("namespace")) {
namespace = "com.bluechilli.flutteruploader"
}
compileSdk 34

defaultConfig {
minSdkVersion 16
minSdk 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

lintOptions {
Expand All @@ -40,11 +43,12 @@ android {
}

dependencies {
implementation "androidx.work:work-runtime:2.7.1"
implementation "androidx.concurrent:concurrent-futures:1.1.0"
implementation "androidx.annotation:annotation:1.2.0"
implementation "androidx.lifecycle:lifecycle-livedata:2.3.1"
implementation "androidx.core:core:1.5.0"
implementation "com.squareup.okhttp3:okhttp:4.9.0"
implementation "com.google.code.gson:gson:2.8.6"
implementation "androidx.work:work-runtime:2.9.0"
implementation "androidx.startup:startup-runtime:1.1.1"
implementation "androidx.concurrent:concurrent-futures:1.2.0"
implementation "androidx.annotation:annotation:1.8.0"
implementation "androidx.lifecycle:lifecycle-livedata:2.8.2"
implementation "androidx.core:core:1.13.1"
implementation "com.squareup.okhttp3:okhttp:4.12.0"
implementation "com.google.code.gson:gson:2.10.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ private MultipartBody.Builder prepareRequest(Map<String, String> parameters, Str

private void sendUpdateProcessEvent(Context context, int status, int progress) {
setProgressAsync(
new Data.Builder().putInt("status", status).putInt("progress", progress).build());
new Data.Builder().putInt(UploadWorker.EXTRA_STATUS, status).putInt("progress", progress).build());
}

private Data createOutputErrorData(
Expand Down
32 changes: 8 additions & 24 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
# flutter_uploader_example

Demonstrates how to use the flutter_uploader plugin.
Demonstrates how to use the `flutter_uploader` plugin. This example includes two basic cloud function endpoints to receive the uploaded files that can be deployed locally or on Firebase.

## Getting Started
## Getting Started - Flutter

# Setup upload Api
To run the app on **iOS** make sure to update signing configuration to use your development certificate. On **Android** you don't need to do any additional setup to run the example app.

1. install firebase-tools in terminal
In the `lib/main.dart` you can define the `uploadURL` to point to your own cloud function (e.g. `http://192.168.1.xx:5001/flutteruploader/us-central1/upload` when running emulator on computer located at `192.168.1.xx` in the local network, needs to match `firebase.json` emulator config).

```console
npm install -g firebase-tools
```

2. create project in firebase console

3. login to firebase in terminal

```console
firebase login
```
On Android you need to manually grant notifications permissions in system settings to see the updates in notification panel. The example app does not prompt for notifications permissions on Android.

4. Go to example/backend/
## Setup Upload Api

5. run

```console
firebase deploy
```

6. run example app
See [backend/README.md](backend/README.md) for instructions on how to setup the cloud functions locally or on Firebase.

## Driver tests

Run the current end to end test suite:

```
flutter drive --driver=test_driver/flutter_uploader_e2e_test.dart test_driver/flutter_uploader_test.dart
```
```
4 changes: 4 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
linter:
rules:
public_member_api_docs: false
avoid_print: false
50 changes: 26 additions & 24 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}


def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +13,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,29 +23,37 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
compileSdkVersion 31
namespace "com.bluechilli.flutteruploaderexample"
ndkVersion flutter.ndkVersion
compileSdk 34

lintOptions {
disable 'InvalidPackage'
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17
}

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.bluechilli.flutteruploaderexample"
minSdkVersion 16
targetSdkVersion 31
minSdkVersion flutter.minSdkVersion
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand All @@ -59,11 +69,3 @@ flutter {
source '../..'
}

dependencies {
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"

testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
118 changes: 63 additions & 55 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,61 +1,69 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.bluechilli.flutteruploaderexample">
xmlns:tools="http://schemas.android.com/tools"
package="com.bluechilli.flutteruploaderexample">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- 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="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:label="flutter_uploader_example"
android:networkSecurityConfig="@xml/network_security_config"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- 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). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- 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="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:label="flutter_uploader_example"
android:networkSecurityConfig="@xml/network_security_config"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
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). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
android:enabled="false"
android:exported="false" />
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:enabled="false"
android:exported="false"
tools:node="merge">
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:enabled="false"
android:exported="false"
android:value="androidx.startup" />
</provider>
<provider
android:name="com.bluechilli.flutteruploader.FlutterUploaderInitializer"
android:authorities="${applicationId}.flutter-uploader-init"
android:exported="false">
<meta-data
android:name="com.bluechilli.flutteruploader.MAX_CONCURRENT_TASKS"
android:value="2" />
<meta-data
android:name="com.bluechilli.flutteruploader.UPLOAD_CONNECTION_TIMEOUT_IN_SECONDS"
android:value="3600" />
</provider>

<provider
android:name="com.bluechilli.flutteruploader.FlutterUploaderInitializer"
android:authorities="${applicationId}.flutter-uploader-init"
android:exported="false">
<meta-data
android:name="com.bluechilli.flutteruploader.MAX_CONCURRENT_TASKS"
android:value="5" />
<meta-data
android:name="com.bluechilli.flutteruploader.UPLOAD_CONNECTION_TIMEOUT_IN_SECONDS"
android:value="3600" />
</provider>

<meta-data android:name="flutterEmbedding" android:value="2"/>
</application>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Loading