gmaps_vehicle_tracker 0.1.1
gmaps_vehicle_tracker: ^0.1.1 copied to clipboard
Smooth, road-aware live vehicle tracking on Google Maps: route matching, bounded prediction, camera follow, built-in vehicle markers and an Uber-style vehicle selector.
import 'package:flutter/material.dart';
import 'demo_routes.dart';
import 'fleet_demo.dart';
import 'gallery_page.dart';
import 'history_demo.dart';
import 'live_demo.dart';
void main() => runApp(const DemoApp());
class DemoApp extends StatelessWidget {
const DemoApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Vehicle Tracker Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(colorSchemeSeed: const Color(0xFF1A73E8), useMaterial3: true),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
final demos = <(IconData, String, String, Widget Function(DemoRoutes))>[
(
Icons.sensors,
'Live tracking',
'Your cab from a noisy, delayed GPS stream, plus nearby cars. Camera modes, outage, debug overlay.',
(r) => LiveDemoPage(routes: r),
),
(
Icons.history,
'History replay',
'Replay a recorded trip with play / pause / seek / speed.',
(r) => HistoryDemoPage(routes: r),
),
(
Icons.local_taxi_outlined,
'Fleet & full map control',
'Many vehicles on an app-built GoogleMap with custom stop markers and your own markers.',
(r) => FleetDemoPage(routes: r),
),
];
return Scaffold(
appBar: AppBar(title: const Text('gmaps_vehicle_tracker')),
body: FutureBuilder<DemoRoutes>(
future: DemoRoutes.load(),
builder: (context, snap) {
final routes = snap.data;
return ListView(
padding: const EdgeInsets.all(12),
children: [
if (routes == null)
const ListTile(leading: CircularProgressIndicator(), title: Text('Loading road routes…'))
else
ListTile(
dense: true,
leading: Icon(routes.online ? Icons.check_circle : Icons.warning_amber,
color: routes.online ? Colors.green : Colors.orange),
title: Text(routes.online
? 'Road routes from Routes API (${routes.nearby.length + 1})'
: 'Offline approximate route — run with --dart-define-from-file=secrets.json'),
),
for (final (icon, title, subtitle, builder) in demos)
Card(
child: ListTile(
enabled: routes != null,
leading: Icon(icon, size: 32),
title: Text(title),
subtitle: Text(subtitle),
trailing: const Icon(Icons.chevron_right),
onTap: routes == null
? null
: () => Navigator.of(context).push(MaterialPageRoute(builder: (_) => builder(routes))),
),
),
Card(
child: ListTile(
leading: const Icon(Icons.directions_bus_outlined, size: 32),
title: const Text('Built-in vehicle gallery'),
subtitle: const Text('All bundled vehicle images at their real marker size, by type.'),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.of(context).push(MaterialPageRoute(builder: (_) => const GalleryPage())),
),
),
],
);
},
),
);
}
}