huawei_location_mx 0.0.2 copy "huawei_location_mx: ^0.0.2" to clipboard
huawei_location_mx: ^0.0.2 copied to clipboard

Huawei location plugin

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:huawei_location/huaweilocation.dart';


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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _message = 'Unknown';
  Huaweilocation _huaweilocation;

  @override
  void initState() {
    super.initState();
    initHuaweiLocation();
  }

  void initHuaweiLocation() async {

    _huaweilocation = new Huaweilocation();
    _huaweilocation.updateLocation().listen((huaweilatlng) {
      setState(() {
        switch(huaweilatlng.code){
          case Huaweilocation.LOCATION_SUCCESS:
            _message = "Latitud: " + huaweilatlng.latitude.toString() + " Longitude" + huaweilatlng.longitude.toString();
            break;

          case Huaweilocation.LOCATION_ERROR:
            _message = huaweilatlng.message;
            break;

          case Huaweilocation.LOCATION_REQUEST_UPDATE_SUCCESS:
            _message = huaweilatlng.message;
            break;

          case Huaweilocation.LOCATION_REQUEST_UPDATE_ERROR:
            _message = huaweilatlng.message;
            break;

          case Huaweilocation.LOCATION_REMOVE_UPDATE:
            _message = huaweilatlng.message;
            break;

          case Huaweilocation.LOCATION_REMOVE_UPDATE_ERROR:
            _message = huaweilatlng.message;
            break;
            
        }
      });
    });

    _huaweilocation.requestLocationUpdates();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('$_message\n'),
        ),
      ),
    );
  }
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

Huawei location plugin

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on huawei_location_mx