几行代码轻松实现flutter 调用百度地图

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class MapDemo extends StatefulWidget {

  const MapDemo({Key? key}) : super(key: key);

  
  State<MapDemo> createState() => _MapDemoState();
}

class _MapDemoState extends State<MapDemo> {
  //平台通道––––跳转到Android页面
  static const platform = MethodChannel('samples.flutter.gsc.android');
//跳转到Android页面
  Future<void> _jumpToAndroidMethod() async {
    final String result = await platform.invokeMethod('jumpToAndroidPage');
    print('result===$result');

  }
  
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("跳转原生地图案例"),centerTitle: true,),
      body: TextButton(onPressed: () {
        _jumpToAndroidMethod();
      },child: Container(
        decoration: const BoxDecoration(
            borderRadius: BorderRadius.all(Radius.circular(20))
        ),
        child: const Text("跳转百度地图定位"),
      ),),
    );
  }
}

效果图

你可能感兴趣的:(flutter,混合开发,android,flutter,android)