From ee2daab06bb30bcd7b893eef1ef22e5ca968d0ad Mon Sep 17 00:00:00 2001 From: Sanni Shafeeq <62085280+Dev-Sashad@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:23:18 +0100 Subject: [PATCH] migration to flutter 3 with package updates --- example/android/app/build.gradle | 33 +++++++++---------- example/android/build.gradle | 14 ++++---- .../gradle/wrapper/gradle-wrapper.properties | 6 ++-- example/android/settings.gradle | 30 +++++++++++------ example/lib/main.dart | 2 +- example/pubspec.yaml | 2 +- lib/src/flutter_google_places.dart | 6 ++-- lib/src/places_autocomplete_field.dart | 4 +-- lib/src/places_autocomplete_form_field.dart | 4 +-- pubspec.yaml | 11 +++---- 10 files changed, 61 insertions(+), 51 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 7d14cfe..e05248b 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,32 +1,31 @@ +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') +def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> + localPropertiesFile.withReader("UTF-8") { reader -> localProperties.load(reader) } } -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') +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = '1' + flutterVersionCode = "1" } -def flutterVersionName = localProperties.getProperty('flutter.versionName') +def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = '1.0' + flutterVersionName = "1.0" } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 32 + compileSdkVersion 34 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -36,8 +35,8 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.yourcompany.example" - minSdkVersion 16 - targetSdkVersion 32 + minSdkVersion 23 + targetSdkVersion 34 versionCode 1 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/example/android/build.gradle b/example/android/build.gradle index ba6fe4a..a14b2c0 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '2.0.20' + repositories { google() - mavenCentral() + jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -14,16 +14,18 @@ buildscript { allprojects { repositories { google() - mavenCentral() + jcenter() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir -} +} \ No newline at end of file diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 0610fc0..f9e1bb1 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Nov 03 15:28:02 CET 2021 +#Tue Nov 26 13:45:53 WAT 2024 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 115da6c..a3334be 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,15 +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 flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withInputStream { stream -> plugins.load(stream) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory +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 "2.0.20" apply false } + +include ":app" \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index ef99be3..d4f01a8 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -3,8 +3,8 @@ import 'dart:math'; import 'package:google_api_headers/google_api_headers.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_google_maps_webservices/places.dart'; import 'package:flutter_google_places/flutter_google_places.dart'; -import 'package:google_maps_webservice/places.dart'; const kGoogleApiKey = "API_KEY"; diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b422c2c..aa34ef7 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -2,7 +2,7 @@ name: example description: A new Flutter project. environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=3.4.3 <4.0.0' dependencies: flutter: diff --git a/lib/src/flutter_google_places.dart b/lib/src/flutter_google_places.dart index a451c36..3f91470 100644 --- a/lib/src/flutter_google_places.dart +++ b/lib/src/flutter_google_places.dart @@ -3,8 +3,8 @@ library flutter_google_places.src; import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_google_maps_webservices/places.dart'; import 'package:google_api_headers/google_api_headers.dart'; -import 'package:google_maps_webservice/places.dart'; import 'package:http/http.dart'; import 'package:rxdart/rxdart.dart'; @@ -142,7 +142,7 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState { ], ), ), - const Divider() + const Divider(), ], ); @@ -375,7 +375,7 @@ class PoweredByGoogleImage extends StatelessWidget { : _poweredByGoogleBlack, scale: 2.5, ), - ) + ), ], ); } diff --git a/lib/src/places_autocomplete_field.dart b/lib/src/places_autocomplete_field.dart index cd16a99..d9e2d16 100644 --- a/lib/src/places_autocomplete_field.dart +++ b/lib/src/places_autocomplete_field.dart @@ -1,8 +1,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_google_maps_webservices/places.dart'; import 'package:flutter_google_places/src/flutter_google_places.dart'; -import 'package:google_maps_webservice/places.dart'; /// A text field like widget to input places with autocomplete. /// @@ -239,7 +239,7 @@ class LocationAutocompleteFieldState extends State { ), ) else - const SizedBox() + const SizedBox(), ], ); diff --git a/lib/src/places_autocomplete_form_field.dart b/lib/src/places_autocomplete_form_field.dart index 9526ead..e83af5b 100644 --- a/lib/src/places_autocomplete_form_field.dart +++ b/lib/src/places_autocomplete_form_field.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:flutter_google_maps_webservices/places.dart'; import 'package:flutter_google_places/src/flutter_google_places.dart'; import 'package:flutter_google_places/src/places_autocomplete_field.dart'; -import 'package:google_maps_webservice/places.dart'; /// A [FormField] that contains a [PlacesAutocompleteField]. /// @@ -40,7 +40,7 @@ class PlacesAutocompleteFormField extends FormField { /// to [initalValue] or the empty string. /// /// For documentation about the various parameters, see the [PlacesAutocompleteField] class - /// and [new PlacesAutocompleteField], the constructor. + /// and [PlacesAutocompleteField.new], the constructor. PlacesAutocompleteFormField({ Key? key, required String apiKey, diff --git a/pubspec.yaml b/pubspec.yaml index 14c8af2..1d59c72 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,18 +1,17 @@ name: flutter_google_places description: Google places autocomplete widgets for flutter. No wrapper, use https://pub.dev/packages/google_maps_webservice -version: 0.4.0 +version: 1.0.0 repository: https://github.com/fluttercommunity/flutter_google_places environment: - sdk: '>=2.12.0 <3.0.0' - flutter: ">=1.17.0" + sdk: '>=3.4.3 <4.0.0' dependencies: flutter: sdk: flutter - google_api_headers: ^1.3.0 - google_maps_webservice: ^0.0.20-nullsafety.5 - http: ^0.13.4 + flutter_google_maps_webservices: ^1.1.1 + google_api_headers: ^4.2.0 + http: ^1.2.2 rxdart: ^0.27.5 dev_dependencies: