yykit 0.0.82 copy "yykit: ^0.0.82" to clipboard
yykit: ^0.0.82 copied to clipboard

a colorful plugin for android & ios.

example/lib/main.dart

import 'dart:convert';

import 'package:yykit/amap_plugin.dart';
import 'package:yykit/map/map_plugin.dart';
import 'package:yykit/model/location/options.dart';
import 'package:yykit/model/method/interface.dart';
import 'package:amap_plugin_example/map/map.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';

import 'nav/nav.dart';
// import 'package:amap_plugin/yykit.dart';

void main() {
  runApp( MaterialApp(
    title: 'My app', // used by the OS task switcher
    home: const MyApp(),
    routes: <String, WidgetBuilder>{
      '/map':(BuildContext context) => const MapView(),
      '/nav':(BuildContext context) => const AMapNavView(),
    },
  ));
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  /// 初始化插件
  final _plugin = AMapUtilities();
  final _navPlugin = MapTools();

  @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('地图插件', style: TextStyle(fontSize: 16, fontWeight: FontWeight.normal),),
          // centerTitle: true,
          elevation: 0,
        ),
        backgroundColor: Colors.white,
        body: ListView(
          children: [
            const ListTile(
              title: Text(
                '关于定位',
                style: TextStyle(
                    color: Colors.black, fontWeight: FontWeight.w900),
              ),
              enabled: false,
              dense: true,
            ),
            ListTile(title: const Text('开启持续定位'), dense: true, onTap: () {
              _plugin.executionMethod(methodName: AMapMethod.location.startLocation, param: LocationOptions().parameters());
            },),
            const Divider(height: 1,),
            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: jsonEncode(LocationOptions().toJson()));
            },),
            const ListTile(
              title: Text(
                '关于地图',
                style: TextStyle(
                    color: Colors.black, fontWeight: FontWeight.w900),
              ),
              enabled: false,
              dense: true,
            ),
            ListTile(title: const Text('地图基础'), dense: true, onTap: () {
              Navigator.push(context, MaterialPageRoute(builder: (context) {
                return const MapView();
              }));
            },),
            ListTile(title: const Text('POI搜索'), dense: true, onTap: () {
              Navigator.push(context, MaterialPageRoute(builder: (context) {
                return const MapView();
              }));
            },),
            const ListTile(
              title: Text(
                '关于导航',
                style: TextStyle(
                    color: Colors.black, fontWeight: FontWeight.w900),
              ),
              enabled: false,
              dense: true,
            ),
            ListTile(title: const Text('调起导航'), dense: true, onTap: () {
              _plugin.executionMethod(methodName: "navigationForDrive", param: "");
            },),
            ListTile(title: const Text('自定义导航'), dense: true, onTap: () {
              Navigator.push(context, MaterialPageRoute(builder: (context) {
                return const AMapNavView();
              }));
            },),
          ],
        )
      ),
    );
  }
}
1
likes
135
points
28
downloads

Publisher

unverified uploader

Weekly Downloads

a colorful plugin for android & ios.

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on yykit