flutter_ymap 1.0.2 copy "flutter_ymap: ^1.0.2" to clipboard
flutter_ymap: ^1.0.2 copied to clipboard

YMap.

example/lib/main.dart

import 'package:example/YMapAPIPage.dart';
import 'package:example/YMapNaviPage.dart';
import 'package:example/YMapPage.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_ymap/YMap.dart';

void main() {
  runApp(const MyApp());
  YMapSDK.init(
    appKey: YAppKey(
      baidu: YAppKey_Baidu(
        android_appkey: "",
        ios_appkey: "",
        android_tts_appId: "",
        ios_tts_appId: "",
        android_tts_apiKey: "",
        ios_tts_apiKey: "",
        android_tts_secretKey: "",
        ios_tts_secretKey: "",
        android_tts_authsn: "",
      ),
      gaode: YAppKey_Gaode(
        android: "",
        ios: "",
      ),
    ),
  );
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'YMap Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'YMap Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: ListView(
        children: [
          ElevatedButton(
            child: Text("地图组件"),
            onPressed: () {
              Navigator.push(context, CupertinoPageRoute(builder: (context) => YMapPage()));
            },
          ),
          ElevatedButton(
            child: Text("导航组件"),
            onPressed: () {
              Navigator.push(context, CupertinoPageRoute(builder: (context) => YMapNaviPage()));
            },
          ),
          ElevatedButton(
            child: Text("地图API"),
            onPressed: () {
              Navigator.push(context, CupertinoPageRoute(builder: (context) => YMapAPIPage()));
            },
          ),
        ],
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}