amap_location_fluttify

This commit is contained in:
2024-11-17 15:42:58 +08:00
commit 3ccab2c601
170 changed files with 40779 additions and 0 deletions

43
example/.gitignore vendored Normal file
View File

@ -0,0 +1,43 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release

0
example/README.md Normal file
View File

View File

@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

View File

@ -0,0 +1,2 @@
#Sat Nov 16 20:14:26 CST 2024
gradle.version=7.4

View File

@ -0,0 +1,66 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
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')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
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
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "me.yohom.amap_location_fluttify_example"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias 'amap_location_test'
keyPassword 'amap_location_test'
storeFile file('../amap_location_test.jks')
storePassword 'amap_location_test'
}
}
buildTypes {
debug {
signingConfig signingConfigs.release
}
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}

View File

View File

@ -0,0 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true

View File

View File

@ -0,0 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

0
example/android/gradlew vendored Normal file
View File

0
example/android/gradlew.bat vendored Normal file
View File

View File

@ -0,0 +1,3 @@
sdk.dir=C:\\Users\\Administrator\\AppData\\Local\\Android\\sdk
flutter.sdk=D:\\futter\\flutter
flutter.buildMode=debug

View File

View File

View File

View File

0
example/ios/Podfile Normal file
View File

0
example/ios/Podfile.lock Normal file
View File

View File

View File

View File

View File

View File

192
example/lib/main.dart Normal file
View File

@ -0,0 +1,192 @@
import 'package:amap_location_fluttify/amap_location_fluttify.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await AmapLocation.instance.updatePrivacyShow(true);
await AmapLocation.instance.updatePrivacyAgree(true);
await AmapLocation.instance.init(iosKey: 'f6422eadda731fb0d9ffb3260a5cf899');
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
Location? _location;
String? _fenceStatus;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Plugin example app')),
body: Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () async {
if (await requestPermission()) {
final location =
await AmapLocation.instance.fetchLocation();
setState(() => _location = location);
}
},
child: Text('获取单次定位'),
),
ElevatedButton(
onPressed: () async {
if (await requestPermission()) {
await AmapLocation.instance.enableBackgroundLocation(
10,
BackgroundNotification(
contentTitle: 'contentTitle',
channelId: 'channelId',
contentText: 'contentText',
channelName: 'channelName',
),
);
AmapLocation.instance
.listenLocation()
.listen((event) => setState(() => _location = event));
}
},
child: Text('获取连续定位'),
),
ElevatedButton(
onPressed: () async {
if (await requestPermission()) {
await AmapLocation.instance.stopLocation();
setState(() => _location = null);
}
},
child: Text('停止定位'),
),
ElevatedButton(
onPressed: () async {
if (await requestPermission()) {
AmapLocation.instance
.addCircleGeoFence(
center: LatLng(29, 119),
radius: 1000,
customId: 'testid',
)
.listen((event) {
setState(() {
_fenceStatus =
'状态: ${event.status}, 围栏id: ${event.fenceId}, 自定义id: ${event.customId}';
});
});
}
},
child: Text('添加圆形围栏'),
),
ElevatedButton(
onPressed: () async {
if (await requestPermission()) {
AmapLocation.instance.addPolygonGeoFence(
pointList: <LatLng>[
LatLng(29.255201, 119.353437),
LatLng(28.974455, 119.508619),
LatLng(29.172496, 119.560804),
LatLng(29.306707, 119.422101),
],
customId: 'testid',
).listen((event) {
setState(() {
_fenceStatus =
'状态: ${event.status}, 围栏id: ${event.fenceId}, 自定义id: ${event.customId}';
});
});
}
},
child: Text('添加多边形围栏'),
),
ElevatedButton(
onPressed: () async {
if (await requestPermission()) {
AmapLocation.instance
.addPoiGeoFence(
keyword: '肯德基',
customId: 'testid',
city: '兰溪',
aroundRadius: 10000,
)
.listen((event) {
setState(() {
_fenceStatus =
'状态: ${event.status}, 围栏id: ${event.fenceId}, 自定义id: ${event.customId}';
});
});
}
},
child: Text('添加poi围栏'),
),
ElevatedButton(
onPressed: () async {
if (await requestPermission()) {
AmapLocation.instance
.addDistrictGeoFence(keyword: '兰溪')
.listen((event) {
setState(() {
_fenceStatus =
'状态: ${event.status}, 围栏id: ${event.fenceId}, 自定义id: ${event.customId}';
});
});
}
},
child: Text('添加行政区划围栏'),
),
ElevatedButton(
onPressed: () {
AmapLocation.instance.dispose();
},
child: Text('释放资源'),
),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
if (_location != null)
Center(
child: Text(
_location.toString(),
textAlign: TextAlign.center,
),
),
if (_fenceStatus != null)
Center(
child: Text(
_fenceStatus.toString(),
textAlign: TextAlign.center,
),
),
],
),
),
),
],
),
),
),
);
}
}
Future<bool> requestPermission() async {
final permissions = await Permission.locationWhenInUse.request();
if (permissions.isGranted) {
return true;
} else {
debugPrint('需要定位权限!');
return false;
}
}

241
example/pubspec.lock Normal file
View File

@ -0,0 +1,241 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
amap_core_fluttify:
dependency: transitive
description:
path: "D:\\FlutterProjects\\amap_core_fluttify"
relative: false
source: path
version: "0.17.0"
amap_location_fluttify:
dependency: "direct dev"
description:
path: ".."
relative: true
source: path
version: "0.22.0"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
clock:
dependency: transitive
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev"
source: hosted
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
core_location_fluttify:
dependency: transitive
description:
path: "D:\\FlutterProjects\\core_location_fluttify"
relative: false
source: path
version: "0.7.1"
fake_async:
dependency: transitive
description:
name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
foundation_fluttify:
dependency: transitive
description:
path: "D:\\FlutterProjects\\foundation_fluttify"
relative: false
source: path
version: "0.13.0+1"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
matcher:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.15.0"
path:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
sha256: e968207ce71d8b40d719aeca3e5a8b684494ecbe9a577dd67cc701216bcccf0a
url: "https://pub.dev"
source: hosted
version: "7.2.0"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: "6760eb5ef34589224771010805bea6054ad28453906936f843a8cc4d3a55c4a4"
url: "https://pub.dev"
source: hosted
version: "3.12.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.5"
sdks:
dart: ">=3.5.3 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"

26
example/pubspec.yaml Normal file
View File

@ -0,0 +1,26 @@
name: amap_location_fluttify_example
description: Demonstrates how to use the amap_location_fluttify plugin.
publish_to: 'none'
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
permission_handler: ^7.1.0
#dependency_overrides:
# foundation_fluttify:
# path: /Users/yohom/Github/Me/All/fluttify/fluttify_infra/foundation_fluttify
# core_location_fluttify:
# path: /Users/yohom/Github/Me/All/fluttify/fluttify_infra/core_location_fluttify
dev_dependencies:
flutter_test:
sdk: flutter
amap_location_fluttify:
path: ../
flutter:
uses-material-design: true

View File