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

outdated

A new Flutter package with chargepoint custom markers.

charge_point_map_package #

A new Flutter package with charge point custom markers.

Dependence #

package use plugin google_maps_flutter: ^0.5.21+15.

Preparation #

The package serves as an addition to the google_maps_flutter plugin. So, firstly, use their instruction.

Usage #

Future

class ChargePointMarker - class extend google_maps_flutter.Marker. All fields are the same except for the icon field. ChargePointMarker have not this field because the package uses a persistent custom icon.

Example #

import 'package:flutter/material.dart';
import 'package:charge_point_map_package/charge_point_map_package.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

void main() => runApp(MyApp());

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

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool isLoading = true;
  Set<ChargePointMarker> markers;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((Duration duration) {
      _asyncInit(context);
    });
  }

  Future<void> _asyncInit(BuildContext context) async {
    await ChargePointMapPackage.initialize(context);
    markers = Set.from([
      ChargePointMarker(
        markerId: MarkerId("new_marker_id"),
        position: LatLng(0, 0),
      ),
    ]);
    setState(() {
      isLoading = false;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: isLoading
            ? Center(
          child: CircularProgressIndicator(),
        )
            : GoogleMap(
            initialCameraPosition: CameraPosition(
                target: LatLng(0, 0), zoom: 2),
            markers: markers),
      ),
    );
  }
}

1
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter package with chargepoint custom markers.

Homepage

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, google_maps_flutter

More

Packages that depend on charge_point_map_package_extrawest