flutter_launcher_plus 0.0.1 copy "flutter_launcher_plus: ^0.0.1" to clipboard
flutter_launcher_plus: ^0.0.1 copied to clipboard

outdated

Plugin to launch url and map coordinates

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

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

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

class _MyAppState extends State<MyApp> {

  String _platformVersion = 'Unknown';
  static const _channel = MethodChannel("flutter_launcher_plus");

  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion =
      await FlutterLauncherPlus.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  Future<void> launchUrl(String websiteUrl) async {
    await _channel.invokeMethod('launchUrl',<String, String>{
      'website_url':websiteUrl
    });
  }

  Future<void> drawRouteFromCurrentLocation(String latitude, String longitude) async {
    await _channel.invokeMethod('drawRouteFromCurrentLocation',<String, String>{
      'latitude':latitude,
      'longitude':longitude,
    });
  }

  Future<void> drawRouteBetweenTwoLocation(String startLatitude, String startLongitude, String endLatitude, String endLongitude) async {
    await _channel.invokeMethod('drawRouteBetweenTwoLocation',<String, String>{
      'startLatitude':startLatitude,
      'startLongitude':startLongitude,
      'endLatitude':endLatitude,
      'endLongitude':endLongitude,
    });
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    initPlatformState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Container(
          alignment: Alignment.center,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[

              Text("version: ${_platformVersion}"),

                ElevatedButton(
                    onPressed: (){
                      launchUrl("http://www.google.com");
                    },
                    child: Text("Launch Url")
                ),

              ElevatedButton(
                  onPressed: (){
                    drawRouteFromCurrentLocation("28.434343","77.33636345");
                  },
                  child: Text("Draw route from current location")
              ),

              ElevatedButton(
                  onPressed: (){
                    drawRouteBetweenTwoLocation("25.3453535", "77.4234232", "25.08274526", "77.97652464");
                  },
                  child: Text("Draw route between two locations")
              )

            ],
          ),
        ),
      ),
    );
  }
}
4
likes
0
points
24
downloads

Publisher

unverified uploader

Weekly Downloads

Plugin to launch url and map coordinates

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_launcher_plus

Packages that implement flutter_launcher_plus