Skip to content

Commit

Permalink
chore: Update Android gradle config, resolve some linting issues (#67)
Browse files Browse the repository at this point in the history
Followed this guide to update Android gradle config to new recommended settings:
https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply

Updated sdk version in example app's pubspec.

Fixed some linting issues after locally updating the flutter_lints package to 5.0.0,
most notably using super parameters. However, that change to use version 5.0.0 could
not be committed because we still support Dart 2.19, which is tied to flutter_lints 2.0.3.
  • Loading branch information
jfahrenkrug authored Oct 9, 2024
1 parent 97cfd50 commit bb64f70
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 50 deletions.
19 changes: 6 additions & 13 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
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 +12,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,10 +22,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

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

android {
compileSdkVersion flutter.compileSdkVersion

Expand Down Expand Up @@ -62,7 +59,3 @@ android {
flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
13 changes: 0 additions & 13 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

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

allprojects {
repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
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-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
30 changes: 22 additions & 8 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

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"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

include ":app"
4 changes: 2 additions & 2 deletions example/lib/async_demo_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import 'package:flutter/material.dart';

/// Simple example of how to use EasyImageViewer with a FutureBuilder
class AsyncDemoPage extends StatefulWidget {
const AsyncDemoPage({Key? key}) : super(key: key);
const AsyncDemoPage({super.key});

@override
_AsyncDemoPageState createState() => _AsyncDemoPageState();
State<AsyncDemoPage> createState() => _AsyncDemoPageState();
}

class _AsyncDemoPageState extends State<AsyncDemoPage> {
Expand Down
8 changes: 4 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -25,12 +25,12 @@ class MyHomePage extends StatefulWidget {
final String title;

const MyHomePage({
Key? key,
super.key,
required this.title,
}) : super(key: key);
});

@override
_MyHomePageState createState() => _MyHomePageState();
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.16.1 <3.0.0"
sdk: ">=2.19.0 <4.0.0" # This implies at least Dart 2.19, which comes with Flutter 3.7.0

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down
2 changes: 1 addition & 1 deletion lib/easy_image_viewer.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// A library to easily display images in a full-screen dialog.
/// It supports pinch & zoom, and paging through multiple images.
library easy_image_viewer;
library;

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/src/easy_image_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class EasyImageView extends StatefulWidget {
/// The optional [doubleTapZoomable] boolean defaults to false and allows double tap to zoom.
const EasyImageView.imageWidget(
this.imageWidget, {
Key? key,
super.key,
this.minScale = 1.0,
this.maxScale = 5.0,
this.doubleTapZoomable = false,
this.onScaleChanged,
}) : super(key: key);
});

@override
State<EasyImageView> createState() => _EasyImageViewState();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/easy_image_view_pager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class EasyImageViewPager extends StatefulWidget {
/// and the [pageController] to control the initial image index to display.
/// The optional [doubleTapZoomable] boolean defaults to false and allows double tap to zoom.
const EasyImageViewPager({
Key? key,
super.key,
required this.easyImageProvider,
required this.pageController,
this.doubleTapZoomable = false,
this.onScaleChanged,
this.infinitelyScrollable = false,
}) : super(key: key);
});

@override
State<EasyImageViewPager> createState() => _EasyImageViewPagerState();
Expand Down
5 changes: 2 additions & 3 deletions lib/src/easy_image_viewer_dismissible_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EasyImageViewerDismissibleDialog extends StatefulWidget {

/// Refer to [showImageViewerPager] for the arguments
const EasyImageViewerDismissibleDialog(this.imageProvider,
{Key? key,
{super.key,
this.immersive = true,
this.onPageChanged,
this.onViewerDismissed,
Expand All @@ -31,8 +31,7 @@ class EasyImageViewerDismissibleDialog extends StatefulWidget {
this.infinitelyScrollable = false,
required this.backgroundColor,
required this.closeButtonTooltip,
required this.closeButtonColor})
: super(key: key);
required this.closeButtonColor});

@override
State<EasyImageViewerDismissibleDialog> createState() =>
Expand Down

0 comments on commit bb64f70

Please sign in to comment.