yykit 0.0.5
yykit: ^0.0.5 copied to clipboard
a colorful plugin for android & ios.
example/lib/main.dart
import 'package:amap_plugin/amap_plugin.dart';
import 'package:amap_plugin/model/location/options.dart';
import 'package:amap_plugin/model/method/interface.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
// import 'package:amap_plugin/yykit.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
/// 初始化插件
final _plugin = AMapUtilities();
@override
void initState() {
super.initState();
/// 设置接收消息方法
_plugin.responseMethod(handleMessage);
}
/// 设置接收消息方法
Future<dynamic> handleMessage(MethodCall call) async {
print(call.method);
print(call.arguments);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: ListView(
children: [
ListTile(title: const Text('开启持续定位'), dense: true, onTap: () {
_plugin.executionMethod(methodName: AMapMethod.location.startLocation, param: LocationOptions().parameters());
},),
ListTile(title: const Text('开启单次定位'), dense: true, onTap: () {
_plugin.executionMethod(methodName: AMapMethod.location.startLocation, param: LocationOptions(isOnceLocation: true).parameters());
},),
ListTile(title: const Text('停止定位'), dense: true, onTap: () {
_plugin.executionMethod(methodName: AMapMethod.location.stopLocation, param: LocationOptions().parameters());
},),
],
)
),
);
}
}