From af169ff22be53beee09396478f38b9270f5b3ccf Mon Sep 17 00:00:00 2001 From: laiiihz Date: Tue, 23 Mar 2021 11:23:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BE=9D=E8=B5=96=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E5=88=B0=E7=A9=BA=E5=AE=89=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 5 +- android/build.gradle | 4 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- lib/main.dart | 4 +- lib/pages/home/home_page.dart | 29 +++-- pubspec.lock | 116 +++++++++--------- pubspec.yaml | 13 +- 7 files changed, 92 insertions(+), 81 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 14b453d..e656489 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -52,7 +52,7 @@ MobSDK { android { - compileSdkVersion 28 + compileSdkVersion 29 lintOptions { disable 'InvalidPackage' @@ -61,7 +61,7 @@ android { defaultConfig { applicationId "com.akuhome.recook" minSdkVersion 22 - targetSdkVersion 28 + targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -134,5 +134,6 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' + implementation 'com.amap.api:location:latest.integration' } diff --git a/android/build.gradle b/android/build.gradle index b3442ee..7eeffe2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.10' + ext.kotlin_version = '1.3.72' ext.flutterFFmpegPackage = 'min-lts' repositories { google() @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:4.0.1' // 注册MobSDK classpath "com.mob.sdk:MobSDK:2018.0319.1724" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index c62691d..27743f3 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -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-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/lib/main.dart b/lib/main.dart index 2360989..d402b68 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,6 @@ import 'dart:convert'; import 'dart:io'; -import 'package:amap_location_fluttify/amap_location_fluttify.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:camera/camera.dart'; import 'package:flutter/material.dart'; @@ -44,8 +43,9 @@ void main() async { WidgetsFlutterBinding.ensureInitialized(); cameras = await availableCameras(); + //TODO ios settings //初始化AMap - AmapLocation.instance.init(iosKey: 'e8a8057cfedcdcadcf4e8f2c7f8de982'); + // AmapLocation.instance.init(iosKey: 'e8a8057cfedcdcadcf4e8f2c7f8de982'); //初始化腾讯im TencentImPlugin.init(appid: '1400435566'); diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index a898de8..f282c8c 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -10,7 +10,8 @@ import 'dart:async'; import 'dart:collection'; import 'dart:convert'; import 'dart:io'; -import 'package:amap_location_fluttify/amap_location_fluttify.dart'; +import 'package:amap_flutter_location/amap_flutter_location.dart'; +import 'package:amap_flutter_location/amap_location_option.dart'; import 'package:clipboard_listener/clipboard_listener.dart'; import 'package:dio/dio.dart'; import 'package:extended_image/extended_image.dart'; @@ -97,7 +98,7 @@ class ClipboardListenerValue { class _HomePageState extends BaseStoreState with TickerProviderStateMixin, WidgetsBindingObserver { - Location _weatherLocation; + Map _weatherLocation; TabController _tabController; int _tabIndex = 0; @@ -152,6 +153,16 @@ class _HomePageState extends BaseStoreState @override void initState() { super.initState(); + requestPermission().then((value) { + if (value) { + AMapFlutterLocation().setLocationOption(AMapLocationOption()); + AMapFlutterLocation().startLocation(); + AMapFlutterLocation().onLocationChanged().listen((event) { + _weatherLocation = event; + }); + } + }); + // 分享注册 _mobShareInit(); // 判断微信是否登录 @@ -252,6 +263,8 @@ class _HomePageState extends BaseStoreState @override void dispose() { _tabController.dispose(); + AMapFlutterLocation().stopLocation(); + AMapFlutterLocation().destroy(); WidgetsBinding.instance.removeObserver(this); super.dispose(); } @@ -458,8 +471,8 @@ class _HomePageState extends BaseStoreState }, ); String locationCityName = - _weatherLocation != null && !TextUtils.isEmpty(_weatherLocation.city) - ? _weatherLocation.city + _weatherLocation != null && !TextUtils.isEmpty(_weatherLocation['city']) + ? _weatherLocation['city'] : ""; try { locationCityName = locationCityName.replaceAll("区", ""); @@ -1365,10 +1378,6 @@ class _HomePageState extends BaseStoreState _getWeather() async { // if (_weatherLocation==null) - - if (await requestPermission()) - _weatherLocation = await AmapLocation.instance.fetchLocation(); - String url = "https://tianqiapi.com/api?version=v61&appid=81622428&appsecret=AxKzYWq3"; if (_weatherCityModel != null && !TextUtils.isEmpty(_weatherCityModel.id)) { @@ -1377,9 +1386,9 @@ class _HomePageState extends BaseStoreState !TextUtils.isEmpty(_weatherCityModel.cityZh)) { url = "$url&city=${_weatherCityModel.cityZh}"; } else if (_weatherLocation != null && - !TextUtils.isEmpty(_weatherLocation.city)) { + !TextUtils.isEmpty(_weatherLocation['city'])) { // url = "$url&point=gaode&lng=${_weatherLocation.latLng.longitude.toString()}&lat=${_weatherLocation.latLng.latitude.toString()}"; - String city = _weatherLocation.city.replaceAll("区", ""); + String city = (_weatherLocation['city'] as String).replaceAll("区", ""); city = city.replaceAll("市", ""); url = "$url&city=$city"; } diff --git a/pubspec.lock b/pubspec.lock index a2aedff..926676f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -8,20 +8,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "18.0.0" - amap_core_fluttify: - dependency: transitive - description: - name: amap_core_fluttify - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.12.0" - amap_location_fluttify: + amap_flutter_location: dependency: "direct main" description: - name: amap_location_fluttify + name: amap_flutter_location url: "https://pub.flutter-io.cn" source: hosted - version: "0.18.0" + version: "1.0.1" analyzer: dependency: transitive description: @@ -56,7 +49,7 @@ packages: name: auto_size_text url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0" + version: "3.0.0-nullsafety.0" azlistview: dependency: "direct main" description: @@ -225,13 +218,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "3.0.0" - core_location_fluttify: - dependency: transitive - description: - name: core_location_fluttify - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.4.1" crypto: dependency: transitive description: @@ -273,14 +259,14 @@ packages: name: device_info url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.0" + version: "2.0.0" device_info_platform_interface: dependency: transitive description: name: device_info_platform_interface url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.1" + version: "2.0.1" dio: dependency: "direct main" description: @@ -357,7 +343,7 @@ packages: name: file_picker url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.7" + version: "3.0.0" fixnum: dependency: transitive description: @@ -397,7 +383,7 @@ packages: name: flutter_ffmpeg url: "https://pub.flutter-io.cn" source: hosted - version: "0.3.1" + version: "0.4.0" flutter_gifimage: dependency: "direct main" description: @@ -411,7 +397,7 @@ packages: name: flutter_highlight url: "https://pub.flutter-io.cn" source: hosted - version: "0.6.0" + version: "0.7.0" flutter_icons: dependency: "direct main" description: @@ -444,7 +430,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.11" + version: "2.0.0" flutter_qr_reader: dependency: "direct main" description: @@ -565,7 +551,7 @@ packages: name: highlight url: "https://pub.flutter-io.cn" source: hosted - version: "0.6.0" + version: "0.7.0" hive: dependency: "direct main" description: @@ -628,14 +614,7 @@ packages: name: image_picker url: "https://pub.flutter-io.cn" source: hosted - version: "0.6.6+5" - image_picker_platform_interface: - dependency: transitive - description: - name: image_picker_platform_interface - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.0.0" + version: "0.6.2+3" intl: dependency: transitive description: @@ -763,7 +742,7 @@ packages: name: package_info url: "https://pub.flutter-io.cn" source: hosted - version: "0.4.3+4" + version: "2.0.0" package_signature: dependency: "direct main" description: @@ -893,7 +872,7 @@ packages: name: plugin_platform_interface url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.3" + version: "2.0.0" pointycastle: dependency: transitive description: @@ -913,7 +892,7 @@ packages: description: path: "." ref: null-safety - resolved-ref: aba917ade1f1a2f104977dce429d0e358e26c621 + resolved-ref: e07ea9aaa832772139172f2a83b5d2babc63fc7e url: "http://159.75.73.143:8080/laiiihz/power_logger" source: git version: "0.1.3" @@ -1000,7 +979,42 @@ packages: name: shared_preferences url: "https://pub.flutter-io.cn" source: hosted - version: "0.5.3+4" + version: "2.0.5" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + shared_preferences_macos: + dependency: transitive + description: + name: shared_preferences_macos + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" sharesdk_plugin: dependency: "direct main" description: @@ -1130,7 +1144,7 @@ packages: name: tobias url: "https://pub.flutter-io.cn" source: hosted - version: "1.6.0+1" + version: "2.0.0-nullsafety.3" typed_data: dependency: transitive description: @@ -1144,14 +1158,7 @@ packages: name: url_launcher url: "https://pub.flutter-io.cn" source: hosted - version: "5.7.10" - url_launcher_linux: - dependency: transitive - description: - name: url_launcher_linux - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.0.1+4" + version: "5.4.0" url_launcher_macos: dependency: transitive description: @@ -1165,21 +1172,14 @@ packages: name: url_launcher_platform_interface url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.9" + version: "1.0.1" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.5+1" - url_launcher_windows: - dependency: transitive - description: - name: url_launcher_windows - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.0.1+3" + version: "0.1.1+5" vector_math: dependency: transitive description: @@ -1214,14 +1214,14 @@ packages: name: video_thumbnail url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.5+1" + version: "0.3.1" video_trimmer: dependency: "direct main" description: path: "." ref: HEAD - resolved-ref: "99336eabeac7332b29a4b1646119a18f3a191dee" - url: "http://192.168.2.201:8099/aku_fe/video_trimmer.git" + resolved-ref: ad8c04b159cfa7c1be2fbf73b68776beb04cd8f7 + url: "http://159.75.73.143:8080/laiiihz/video_trimmer" source: git version: "0.3.5" wakelock: diff --git a/pubspec.yaml b/pubspec.yaml index 37759e7..c12afe9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,8 @@ dependencies: timeline_tile: 0.1.2 # 高德定位 - amap_location_fluttify: + # amap_location_fluttify: ^0.18.0 + amap_flutter_location: ^1.0.1 # icons flutter_icons: 1.1.0 # 拼音 @@ -94,7 +95,7 @@ dependencies: oktoast: 2.3.2 # 应用信息 - package_info: ^0.4.0+16 + package_info: ^2.0.0 #缓存图片 # cached_network_image: ^1.1.0 @@ -126,10 +127,10 @@ dependencies: # 源码 TobiasPlugin.m # 判断支付宝是否安装时 源码不正确 应将 alipays 改为 alipay #########################3 # - tobias: 1.6.0+1 + tobias: 2.0.0-nullsafety.3 # 小数据缓存 - shared_preferences: 0.5.3+4 + shared_preferences: ^2.0.5 # 屏幕适配 flutter_screenutil: ^0.5.3 @@ -203,7 +204,7 @@ dependencies: #视频剪辑 video_trimmer: git: - url: http://192.168.2.201:8099/aku_fe/video_trimmer.git + url: http://159.75.73.143:8080/laiiihz/video_trimmer #点赞组件 many_like: ^0.0.6 @@ -226,7 +227,7 @@ dependencies: pin_input_text_field: ^3.3.0 - device_info: ^1.0.0 + device_info: ^2.0.0 clipboard_listener: ^1.0.0 power_logger: git: