Skip to content

A Flutter-based time tracking app with geofencing capabilities that automatically tracks time spent at predefined locations. Features include background location tracking, clock in/out functionality, and daily time summaries. Built with modern Flutter practices using go_router for navigation, Hive for local storage, and efficient location services.

Notifications You must be signed in to change notification settings

appdever01/flutter-time-tracker

Repository files navigation

Flutter Time Tracker

A modern Flutter application for tracking time spent at different locations using geofencing technology. The app automatically detects when you're at predefined locations (Home, Office) or traveling, and provides detailed daily summaries of your time allocation.

Features

Core Functionality

  • Automatic Location Tracking: Uses GPS and geofencing to detect your current location
  • Predefined Geofences: Tracks time at Home and Office locations with 50-meter radius detection
  • Background Tracking: Continues monitoring location even when app is minimized
  • Daily Summaries: Comprehensive breakdown of time spent in each location
  • Historical Data: View past tracking data with date picker navigation
  • Real-time Updates: Live tracking status and time calculations

User Interface

  • Clean Modern Design: Sleek, minimalistic interface without shadows
  • Intuitive Navigation: Simple Clock In/Out workflow with visual feedback
  • Color-coded Status: Different colors for active tracking, stopped, and location states
  • Responsive Layout: Optimized for mobile devices with touch-friendly controls

Data Management

  • Local Storage: Uses Hive database for efficient local data persistence
  • Custom Geofences: Support for adding user-defined locations (bonus feature)
  • Data Export: Time entries and summaries stored in structured format
  • Privacy First: All data stored locally on device

Technical Stack

Framework & Languages

  • Flutter: Cross-platform mobile development framework
  • Dart: Programming language
  • Material Design 3: Modern UI components and theming

Core Dependencies

  • go_router: Navigation and routing management
  • provider: State management solution
  • hive: Local database for data persistence
  • location: Background location tracking
  • geolocator: GPS and location services
  • permission_handler: Runtime permission management
  • intl: Internationalization and date formatting

Architecture

  • Provider Pattern: Reactive state management
  • Service Layer: Separation of business logic
  • Repository Pattern: Data access abstraction
  • Clean Architecture: Modular and testable code structure

Project Structure

lib/
├── models/           # Data models with Hive annotations
│   ├── location_data.dart
│   ├── geofence_data.dart
│   ├── time_entry.dart
│   └── daily_summary.dart
├── providers/        # State management
│   ├── location_provider.dart
│   └── time_tracking_provider.dart
├── services/         # Business logic services
│   ├── location_service.dart
│   ├── geofence_service.dart
│   ├── hive_service.dart
│   └── tracking_coordinator.dart
├── screens/          # UI screens
│   ├── splash_screen.dart
│   ├── main_screen/
│   └── summary_screen/
├── utils/            # Utilities and helpers
│   └── app_router.dart
└── main.dart         # Application entry point

Setup Instructions

Prerequisites

  • Flutter SDK (3.2.0 or higher)
  • Android Studio / Xcode for mobile development
  • Git for version control

Installation

  1. Clone the repository

    git clone <repository-url>
    cd test-app
  2. Install dependencies

    flutter pub get
  3. Generate code (for Hive type adapters)

    flutter packages pub run build_runner build
  4. Run the application

    flutter run

Platform Configuration

Android Setup

  • Minimum SDK: 21
  • Target SDK: 34
  • Permissions automatically handled in AndroidManifest.xml

iOS Setup

  • Minimum iOS version: 12.0
  • Location permissions configured in Info.plist
  • Background location capability enabled

Usage

Getting Started

  1. Launch the app - The splash screen will initialize all services
  2. Grant permissions - Allow location access when prompted
  3. Clock In - Tap the large blue button to start tracking
  4. Move around - App automatically detects location changes
  5. Clock Out - Tap the red button to stop tracking and save data
  6. View Summary - Navigate to summary screen to see detailed breakdowns

Default Locations

  • Home: 37.7749°N, 122.4194°W (San Francisco area)
  • Office: 37.7858°N, 122.4364°W (San Francisco area)
  • Traveling: When outside any defined geofence

Viewing Data

  • Today's Live Data: Real-time tracking on main screen
  • Historical Summaries: Use date picker in summary screen
  • Location Breakdown: See time and percentage spent in each location
  • Progress Visualization: Color-coded progress bars for each location

App Architecture

State Management

The app uses the Provider pattern with multiple providers:

  • LocationProvider: Manages GPS tracking and geofence detection
  • TimeTrackingProvider: Handles time calculations and data persistence

Data Flow

  1. LocationService monitors GPS coordinates
  2. GeofenceService determines current location based on coordinates
  3. TrackingCoordinator synchronizes location changes with time tracking
  4. Providers update UI state and persist data to Hive database

Background Processing

  • Location updates continue when app is backgrounded
  • Time entries are automatically saved when location changes
  • Daily summaries generated and stored on Clock Out

Permissions

Android

  • ACCESS_FINE_LOCATION: High-accuracy GPS tracking
  • ACCESS_COARSE_LOCATION: Network-based location
  • ACCESS_BACKGROUND_LOCATION: Background location updates
  • FOREGROUND_SERVICE: Service for continuous tracking
  • WAKE_LOCK: Prevent device sleep during tracking

iOS

  • NSLocationWhenInUseUsageDescription: Location access when app is active
  • NSLocationAlwaysAndWhenInUseUsageDescription: Background location access
  • UIBackgroundModes: Background location updates

Development

Building for Release

flutter build apk --release          # Android
flutter build ios --release          # iOS

Code Generation

When modifying Hive models, regenerate type adapters:

flutter packages pub run build_runner build --delete-conflicting-outputs

Testing

flutter test                         # Unit tests
flutter analyze                      # Static analysis

Troubleshooting

Common Issues

Location permissions denied

  • Check device location settings
  • Ensure app has location permissions in system settings
  • For iOS, check Location Services is enabled

Background tracking not working

  • Verify background app refresh is enabled
  • Check battery optimization settings
  • Ensure location permissions include "Always" option

Build errors

  • Run flutter clean and flutter pub get
  • Check Android NDK version matches requirements
  • Ensure all dependencies are compatible

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Flutter team for the excellent framework
  • Community packages that made this project possible
  • Contributors and testers who helped improve the app

About

A Flutter-based time tracking app with geofencing capabilities that automatically tracks time spent at predefined locations. Features include background location tracking, clock in/out functionality, and daily time summaries. Built with modern Flutter practices using go_router for navigation, Hive for local storage, and efficient location services.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages