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

A Flutter package which can be used to make polylines(route) from a source to a destination, and make smooth animation when source start moving towards destination with smooth polyline removal from be [...]

example/lib/main.dart

import 'dart:async';
import 'package:casa_google_map/casa_google_map.dart';
import 'package:example/screens/freelancer_screen.dart';
import 'package:example/services/firestore_service.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_background_service_android/flutter_background_service_android.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const CasaMapFreelancerExample(),
    );
  }
}

void startBackgroundService(ServiceInstance service) {
  debugPrint("_startBackgroundService");
  if (service is AndroidServiceInstance) {
    service.on('setAsForeground').listen((event) {
      service.setAsForegroundService();
    });
    service.on('setAsBackground').listen((event) {
      service.setAsBackgroundService();
    });
  }
  service.on('stopService').listen((event) {
    service.stopSelf();
  });
  // bring to foreground
  Timer.periodic(
    const Duration(seconds: 5),
    (timer) async {
      if (service is AndroidServiceInstance) {
        await service.setForegroundNotificationInfo(
            title: 'CASA', content: 'Running Background Service.');
      }

      debugPrint("Timer Periodic");

      listenDeviceLocation();
    },
  );
}

listenDeviceLocation() {
  debugPrint("Hurra listenDeviceLocation working");
  CasaMapService casaMapService = CasaMapService();
  casaMapService
      .startListeningToDriverLocation(
          locationSettings: const LocationSettings(
              distanceFilter: 20, accuracy: LocationAccuracy.high))
      .listen((position) {
    CasaPosition casaPosition = CasaPosition(
        driverLatLng: LatLng(position.latitude, position.longitude),
        destinationLatLng: destinationLatLng);
    FirestoreService.updateLocationInFirebase(casaPosition);
  });
}
3
likes
70
pub points
35%
popularity

Publisher

verified publishertechroomteam.com

A Flutter package which can be used to make polylines(route) from a source to a destination, and make smooth animation when source start moving towards destination with smooth polyline removal from behind and also handle a driver's realtime location (if any) on the map.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, flutter_compass, flutter_polyline_points, geolocator, google_map_marker_animation, google_maps_flutter, maps_toolkit, url_launcher

More

Packages that depend on casa_google_map