Skip to content

Commit

Permalink
AGP 8, Flutter 3, Dart 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
wrbl606 committed Sep 1, 2023
1 parent 6abc21b commit 6cfa862
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 73 deletions.
15 changes: 10 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,30 @@ version '1.0-SNAPSHOT'
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

rootProject.allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 28
// Conditional for compatibility with AGP <4.2.
if (project.android.hasProperty("namespace")) {
namespace 'eu.wroblewscy.marcin.imagecrop'
}

compileSdkVersion 33

defaultConfig {
minSdkVersion 16
Expand All @@ -34,5 +39,5 @@ android {
}

dependencies {
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.6'
}
15 changes: 10 additions & 5 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28

lintOptions {
disable 'InvalidPackage'
// Conditional for compatibility with AGP <4.2.
if (project.android.hasProperty("namespace")) {
namespace 'eu.wroblewscy.marcin.imagecropexample'
}

compileSdkVersion 33


defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "eu.wroblewscy.marcin.imagecropexample"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -48,6 +50,9 @@ android {
signingConfig signingConfigs.debug
}
}
lint {
disable 'InvalidPackage'
}
}

flutter {
Expand Down
26 changes: 16 additions & 10 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.wroblewscy.marcin.imagecropexample">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
Expand All @@ -13,7 +12,7 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:label="image_crop_plus_example">
<activity
Expand All @@ -23,18 +22,25 @@
android:launchMode="singleTop"
android:screenOrientation="userPortrait"
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). -->
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- Specify that the launch screen should continue being displayed -->
<!-- until Flutter renders its first frame. -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true"/>
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />

<!-- Theme to apply as soon as Flutter begins rendering frames -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<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,4 @@
package eu.wroblewscy.marcin.imagecropexample;

import io.flutter.embedding.android.FlutterActivity;
public class MainActivity extends FlutterActivity { }
5 changes: 5 additions & 0 deletions example/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<style name="NormalTheme" 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>
</resources>
8 changes: 4 additions & 4 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand All @@ -24,6 +24,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
5 changes: 5 additions & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
3 changes: 1 addition & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Sat Jun 01 05:20:09 PDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
12 changes: 6 additions & 6 deletions example/ios/Flutter/Flutter.podspec
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#
# NOTE: This podspec is NOT to be published. It is only used as a local source!
# This is a generated file; do not edit or check into version control.
# This podspec is NOT to be published. It is only used as a local source!
# This is a generated file; do not edit or check into version control.
#

Pod::Spec.new do |s|
s.name = 'Flutter'
s.version = '1.0.0'
s.summary = 'High-performance, high-fidelity mobile apps.'
s.homepage = 'https://flutter.io'
s.license = { :type => 'MIT' }
s.summary = 'A UI toolkit for beautiful and fast apps.'
s.homepage = 'https://flutter.dev'
s.license = { :type => 'BSD' }
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
s.ios.deployment_target = '11.0'
# Framework linking is handled by Flutter tooling, not CocoaPods.
# Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
s.vendored_frameworks = 'path/to/nothing'
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
11 changes: 7 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -164,7 +164,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0910;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -227,10 +227,12 @@
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand All @@ -241,6 +243,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -333,7 +336,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -380,7 +383,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
4 changes: 4 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
27 changes: 15 additions & 12 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class MyApp extends StatefulWidget {

class _MyAppState extends State<MyApp> {
final cropKey = GlobalKey<CropState>();
File _file;
File _sample;
File _lastCropped;
File? _file;
File? _sample;
File? _lastCropped;

@override
void dispose() {
Expand Down Expand Up @@ -59,7 +59,7 @@ class _MyAppState extends State<MyApp> {
children: <Widget>[
Expanded(
child: Crop.file(
_sample,
_sample!,
key: cropKey,
),
),
Expand All @@ -74,8 +74,8 @@ class _MyAppState extends State<MyApp> {
'Crop Image',
style: Theme.of(context)
.textTheme
.button
.copyWith(color: Colors.white),
.labelLarge
?.copyWith(color: Colors.white),
),
onPressed: () => _cropImage(),
),
Expand All @@ -91,7 +91,10 @@ class _MyAppState extends State<MyApp> {
return TextButton(
child: Text(
'Open Image',
style: Theme.of(context).textTheme.button.copyWith(color: Colors.white),
style: Theme.of(context)
.textTheme
.labelLarge
?.copyWith(color: Colors.white),
),
onPressed: () => _openImage(),
);
Expand All @@ -100,10 +103,10 @@ class _MyAppState extends State<MyApp> {
Future<void> _openImage() async {
final pickedFile =
await ImagePicker().getImage(source: ImageSource.gallery);
final file = File(pickedFile.path);
final file = File(pickedFile!.path);
final sample = await ImageCrop.sampleImage(
file: file,
preferredSize: context.size.longestSide.toInt() * 2,
preferredSize: context.size!.longestSide.toInt() * 2,
);

_sample?.delete();
Expand All @@ -116,8 +119,8 @@ class _MyAppState extends State<MyApp> {
}

Future<void> _cropImage() async {
final scale = cropKey.currentState.scale;
final area = cropKey.currentState.area;
final scale = cropKey.currentState!.scale;
final area = cropKey.currentState!.area;
if (area == null) {
// cannot crop, widget is not setup
return;
Expand All @@ -126,7 +129,7 @@ class _MyAppState extends State<MyApp> {
// scale up to use maximum possible number of pixels
// this will sample image in higher resolution to make cropped image larger
final sample = await ImageCrop.sampleImage(
file: _file,
file: _file!,
preferredSize: (2000 / scale).round(),
);

Expand Down
Loading

0 comments on commit 6cfa862

Please sign in to comment.