Delivery App
A mobile app I built to explore real-time tracking and Flutter.
I wanted to see how difficult it is to build a real-time logistics app, so I tried making this DoorDash-style delivery app. It was a great way to learn about state management and how to keep a mobile app in sync with a database.
Why I built this
I was curious about Flutter and how it handles complex animations and real-time data. Building a delivery app allowed me to experiment with both, plus I got to work with the Google Maps API for the first time.
How it works
- Flutter & Dart: I used Flutter for the cross-platform UI. I really like how easy it is to make smooth transitions.
- Provider: This is what I used for state management. It handles everything from the user's cart to their authentication state.
- Firebase: I used Firebase for the backend because its real-time listeners are perfect for tracking driver locations without any manual refreshing.
A technical challenge
The hardest part was keeping the driver's location updated on the map without lagging the app. I had to learn how to throttle the updates so I wasn't sending data to Firebase every single second.
// Throttling the location updates
void _updateDriverLocation(Position position) {
final latLng = LatLng(position.latitude, position.longitude);
_mapController?.animateCamera(CameraUpdate.newLatLng(latLng));
// Sync with Firebase
FirebaseDatabase.instance.ref('deliveries/${orderId}/location').set({
'lat': position.latitude,
'lng': position.longitude,
'timestamp': ServerValue.timestamp,
});
}
Things I learned
I realized that high-accuracy GPS can really drain a phone's battery. I had to experiment with the distanceFilter setting in the Geolocator plugin to find a balance between accurate tracking and battery life.
What's next
I want to try adding a dashboard for drivers so they can see their earnings over time, and maybe implement a better routing algorithm for multi-stop deliveries.