galli_navigation 0.0.3 galli_navigation: ^0.0.3 copied to clipboard
A Galli Navigation Package that works well with Galli Vector Plugin, It has two main methods navigate and navigateWithLatLng
import 'package:example/choose_end.dart';
import 'package:example/choose_start.dart';
import 'package:flutter/material.dart';
import 'package:galli_navigation/galli_navigation.dart';
import 'package:galli_vector_plugin/galli_vector_plugin.dart';
import 'package:get/route_manager.dart';
void main() async {
runApp(const MyApp());
}
LatLng? start;
LatLng? end;
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const ChooseStart(),
);
}
}
class Navigate extends StatefulWidget {
const Navigate({super.key});
@override
State<Navigate> createState() => _NavigateState();
}
class _NavigateState extends State<Navigate> {
final TextEditingController _source =
TextEditingController(text: "${start!.latitude}, ${start!.longitude}");
final TextEditingController _destination =
TextEditingController(text: "${end!.latitude}, ${end!.longitude}");
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
InkWell(
onTap: () {
Get.offAll(() => ChooseStart());
},
child: TextField(
enabled: false,
controller: _source,
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: "SOURCE LATLNG",
hintText: "${start!.latitude}, ${start!.longitude}"),
),
),
const SizedBox(
height: 32,
),
InkWell(
onTap: () {
Get.offAll(() => const ChooseEnd());
},
child: TextField(
enabled: false,
controller: _destination,
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: "DESTINATION LATLNG",
hintText: "${end!.latitude}, ${end!.longitude}"),
),
),
const SizedBox(
height: 48,
),
ElevatedButton(
onPressed: () async {
GalliMethods methods = GalliMethods("auth_token");
List sourceList = _source.text.split(",");
List destinationList = _destination.text.split(",");
LatLng source = LatLng(
double.parse(sourceList[0]), double.parse(sourceList[1]));
LatLng destination = LatLng(double.parse(destinationList[0]),
double.parse(destinationList[1]));
///navigate with latlng
methods.navigateWithLatLng(
context: context,
source: source,
destination: destination,
method: RoutingMethods.driving);
///navigate
// var navJson = await methods.getNavigationData(
// source: source,
// destination: destination,
// method: RoutingMethods.walking);
// NavigationModel navData =
// NavigationModel.fromJson(navJson["routes"].first);
// methods.navigate(
// context: context,
// navData: navData,
// method: RoutingMethods.driving);
},
style: ButtonStyle(
elevation: MaterialStateProperty.all(8),
animationDuration: const Duration(milliseconds: 500),
enableFeedback: true,
),
child: const Text("NAVIAGATE"),
),
],
),
),
)),
);
}
}