A Flutter mobile app that automatically detects accidents and sends emergency alerts with the user's live location.
- Automatic Accident Detection: Uses device accelerometer sensors to detect sudden impacts. If the impact force exceeds 4g, it triggers an emergency alert.
- Emergency Alerts: Sends SMS with Google Maps location link to emergency contacts when an accident is detected.
- User Authentication: Sign in via Google, Email/Password.
- Live Location Tracking: Fetches and displays the user's live location when an accident is detected.
- Accident History: Stores and displays accident timestamps, location, and severity.
The Accident Report System now includes an AI-powered Emergency Guidance Assistant that provides real-time guidance during accident situations. This feature is designed to:
- Provide immediate post-accident guidance based on accident context
- Answer questions about what to do in emergency situations
- Offer structured advice categorized by priority
- EmergencyGuidanceAI Service: Core service that handles AI interactions using Google's Gemini AI
- GuidanceMessage Model: Structured representation of AI guidance with immediate actions, secondary steps, and safety warnings
- AccidentContext Model: Captures accident details for contextually relevant guidance
- EmergencyGuidanceScreen: Interactive UI for communicating with the AI assistant
- Emergency Dashboard: Quick access widget for emergency resources
- The system creates an
AccidentContextwith details from the accident report - The AI generates structured guidance based on this context
- Guidance is displayed in a user-friendly format with priority-based sections
- Users can ask follow-up questions through the chat interface
The AI system includes robust fallback mechanisms to ensure guidance is available even if:
- API connections fail
- The AI response format is unexpected
- The device is offline
- AI interactions are logged anonymously for system improvement
- No personally identifiable information is sent to the AI service
- Recent guidance is stored locally for offline access
- Flutter SDK (3.7.2 or later)
- Firebase account
- Android Studio or VS Code
- Android device or emulator (API Level 33 recommended)
-
Create a new Firebase project at Firebase Console
-
Add an Android app to your Firebase project
- Use package name:
com.example.accident_report_system - Download the
google-services.jsonfile
- Use package name:
-
Place the
google-services.jsonfile in theandroid/appdirectory -
Enable Firebase Authentication methods:
- Email/Password
- Google Sign-in
-
Create Firestore Database with the following collections:
users- To store user data and emergency contactsaccidents- To store accident reports
- Create a Google Maps API key in the Google Cloud Console
- Add the API key to
android/app/src/main/AndroidManifest.xml:
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY"/>The app requires the following permissions:
- Location (for tracking user's position)
- SMS (for sending emergency alerts)
- Sensors (for detecting accidents)
- Clone the repository
- Install dependencies:
flutter pub get - Run the app:
flutter run
- Sign in/Register: Create an account using email or Google sign-in.
- Add Emergency Contacts: Add phone numbers of emergency contacts in the Emergency Contacts screen.
- Enable Accident Monitoring: On the home screen, toggle the monitoring switch to start accident detection.
- View Accident History: Check past accidents in the Accident History screen.
- Manual Alert: Send a manual emergency alert with your current location.
- Flutter (Dart): Frontend UI
- Firebase Auth: User authentication
- Firebase Firestore: Database for storing user data and accident reports
- Google Maps API: Display accident locations
- sensors_plus: Accelerometer data for accident detection
- geolocator: Access device GPS coordinates
- flutter_sms: Send emergency SMS alerts
- For testing, you can use the "Send Manual Alert" button instead of simulating an actual accident.
- The app is optimized for Android devices and may require additional setup for iOS.
- Ensure emergency contacts have valid phone numbers that can receive SMS messages.
- Replace
YOUR_GEMINI_API_KEYin theEmergencyGuidanceAIservice with a valid API key - Make sure all required dependencies are installed:
flutter pub add google_generative_ai cloud_firestore shared_preferences
- Integration with telematics data for more accurate accident detection
- Multi-language support for international users
- Voice interface for hands-free operation
