├── .gitignore ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── mrnpro │ │ │ │ └── go_find_taxi │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── assets ├── animations │ └── .gitkeep ├── colors │ └── .gitkeep ├── domain │ └── .well-known │ │ ├── apple-app-site-association │ │ └── assetlinks.json ├── icons │ └── .gitkeep ├── images │ ├── .gitkeep │ └── location_avatar.png ├── jsons │ ├── map_style.json │ └── search.json └── svgs │ ├── .gitkeep │ ├── bus_icon.svg │ ├── bus_service.svg │ ├── filter.svg │ ├── home.svg │ ├── location.svg │ ├── map.svg │ ├── navigate.svg │ ├── profile.svg │ ├── route_progress.svg │ ├── route_progress_vertical.svg │ └── taxi_service.svg ├── firebase.json ├── ios ├── .gitignore ├── Config.xcconfig ├── Flutter │ └── AppFrameworkInfo.plist ├── Podfile ├── Podfile.lock ├── Runner.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Config.xcconfig.template │ ├── Info.plist │ ├── Runner-Bridging-Header.h │ └── Runner.entitlements └── RunnerTests │ └── RunnerTests.swift ├── lib ├── _shared │ ├── data │ │ ├── models │ │ │ └── .gitkeep │ │ └── repo │ │ │ └── .gitkeep │ └── presentation │ │ ├── dialog │ │ └── .gitkeep │ │ ├── provider │ │ └── base_provider.dart │ │ ├── screens │ │ ├── .gitkeep │ │ └── error_screen.dart │ │ └── widgets │ │ ├── .gitkeep │ │ ├── app_container.dart │ │ ├── back_btn.dart │ │ ├── border_less_text_field.dart │ │ └── navigation.dart ├── app.dart ├── core │ ├── analytics │ │ └── observers │ │ │ ├── observers.dart │ │ │ └── riverpod_loger.dart │ ├── barrels │ │ └── all_screens_barrel.dart │ ├── config │ │ ├── api │ │ │ └── api_endpoints.dart │ │ ├── router │ │ │ ├── redirection.dart │ │ │ ├── route_name.dart │ │ │ └── router.dart │ │ └── theme │ │ │ ├── color_pallete.dart │ │ │ └── theme_config.dart │ ├── constants.dart │ ├── constants │ │ └── assets.dart │ ├── extentions │ │ ├── app_shimmer.dart │ │ └── date_extention.dart │ ├── handlers │ │ ├── dio_error_handler.dart │ │ ├── error_handler.dart │ │ ├── failure │ │ │ └── failure.dart │ │ ├── result.dart │ │ └── success │ │ │ └── success.dart │ ├── interceptors │ │ └── dio_interceptor.dart │ ├── services │ │ ├── LocationService │ │ │ ├── from_server_impl.dart │ │ │ ├── gebeta_maps_impl.dart │ │ │ ├── google_map_impl.dart │ │ │ ├── location_service.dart │ │ │ └── models │ │ │ │ ├── direction.dart │ │ │ │ ├── geo_coding_response.dart │ │ │ │ ├── geo_coding_response.freezed.dart │ │ │ │ ├── geo_coding_response.g.dart │ │ │ │ ├── reverse_geocoding_response.dart │ │ │ │ ├── reverse_geocoding_response.freezed.dart │ │ │ │ └── reverse_geocoding_response.g.dart │ │ ├── NetworkConnectionChecker │ │ │ └── data_connection_checker.dart │ │ ├── OnlineService │ │ │ └── httpService │ │ │ │ ├── http_service.dart │ │ │ │ ├── http_service.g.dart │ │ │ │ └── http_service_impl.dart │ │ ├── index.dart │ │ ├── launch_service.dart │ │ └── localService │ │ │ ├── local_service.dart │ │ │ ├── local_service_impl.dart │ │ │ ├── local_service_provider.dart │ │ │ └── local_service_provider.g.dart │ └── utils │ │ ├── index.dart │ │ └── src │ │ ├── calculate_distance.dart │ │ ├── color_utils.dart │ │ ├── date_util.dart │ │ ├── debounce.dart │ │ ├── leg_utils.dart │ │ ├── location_util.dart │ │ ├── print_util.dart │ │ ├── safe_ui_api_call.dart │ │ ├── simulate.dart │ │ └── text_field_validator.dart ├── firebase_options.dart ├── hooks │ └── debounce.dart ├── main.dart └── modules │ ├── home │ └── presentation │ │ └── home_page_page.dart │ └── transit │ ├── core │ ├── map_utils.dart │ ├── price_calculator.dart │ └── search_focus_enum.dart │ ├── data │ ├── datasource │ │ ├── redat_data_source.dart │ │ ├── transit_data_source.dart │ │ └── weyalaw_data_source.dart │ ├── models │ │ ├── redat-model │ │ │ ├── coordinates_redatmodel.dart │ │ │ ├── place_redatmodel.dart │ │ │ ├── transport_option_redatmodel.dart │ │ │ └── transport_step_redatmodel.dart │ │ ├── route.dart │ │ ├── route_model.dart │ │ ├── transport_place_model.dart │ │ ├── transport_route.dart │ │ └── weyalaw-model │ │ │ ├── coordinates_weyalawmodel.dart │ │ │ ├── place_weyalawmodel.dart │ │ │ ├── transport_option_weyalawmodel.dart │ │ │ └── transport_step_weyalawmodel.dart │ └── repositories │ │ └── remote │ │ ├── i_route_remote.dart │ │ ├── i_route_remote.g.dart │ │ └── route_remote_impl.dart │ ├── entities │ ├── coordinates_entity.dart │ ├── place_entity.dart │ ├── transport_option_entity.dart │ └── transport_step_entity.dart │ └── presentation │ ├── dialogs │ ├── .gitkeep │ └── no_route_found_alert.dart │ ├── pages │ ├── error_screen.dart │ ├── main_screen.dart │ ├── pages.dart │ ├── recent-transits │ │ └── recent_transit_screen.dart │ ├── ride_details_screen.dart │ ├── searchPage │ │ ├── components │ │ │ ├── back_button.dart │ │ │ ├── components.dart │ │ │ ├── location_picker.dart │ │ │ └── set_new_destination.dart │ │ └── search_page.dart │ ├── search_screen.dart │ ├── see_all_transport_route.dart │ ├── share_location_wrapper.dart │ ├── start-navigate │ │ └── start_navigation_screen.dart │ └── transitOverview │ │ ├── components │ │ ├── components.dart │ │ └── selected_route_detailed_information.dart │ │ └── transit_overview_page.dart │ ├── providers │ ├── .gitkeep │ ├── current-location-name │ │ ├── get_current_location_name.dart │ │ └── get_current_location_name.g.dart │ ├── get-recent-transits │ │ ├── recent_transits_provider.dart │ │ └── recent_transits_provider.g.dart │ ├── getTransportRouteFromTwoPlace │ │ ├── get_transport_route_from_two_place_notifier.dart │ │ ├── get_transport_route_from_two_place_notifier.g.dart │ │ └── state │ │ │ ├── get_transport_route_from_two_place_state.dart │ │ │ └── get_transport_route_from_two_place_state.freezed.dart │ ├── searchRoute │ │ ├── search_route_notifier.dart │ │ ├── search_route_notifier.g.dart │ │ └── state │ │ │ ├── search_route_state.dart │ │ │ └── search_route_state.freezed.dart │ └── transportRoute │ │ ├── state │ │ ├── transport_route_state.dart │ │ └── transport_route_state.freezed.dart │ │ ├── transport_route_notifier.dart │ │ └── transport_route_notifier.g.dart │ └── widgets │ ├── background_map.dart │ ├── route_display_widget.dart │ ├── transport_routes_list.dart │ └── widgets.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── mason-lock.json ├── mason.yaml ├── pubspec.lock ├── pubspec.yaml ├── web ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter/Dart 2 | .dart_tool/ 3 | .flutter-plugins 4 | .flutter-plugins-dependencies 5 | .packages 6 | .pub-cache/ 7 | .pub/ 8 | build/ 9 | coverage/ 10 | *.class 11 | *.log 12 | *.pyc 13 | *.swp 14 | .DS_Store 15 | .atom/ 16 | .buildlog/ 17 | .history 18 | .svn/ 19 | 20 | # Android 21 | **/android/**/gradle-wrapper.jar 22 | **/android/.gradle 23 | **/android/captures/ 24 | **/android/gradlew 25 | **/android/gradlew.bat 26 | **/android/local.properties 27 | **/android/**/GeneratedPluginRegistrant.java 28 | **/android/key.properties 29 | *.jks 30 | 31 | # iOS 32 | **/ios/**/*.mode1v3 33 | **/ios/**/*.mode2v3 34 | **/ios/**/*.moved-aside 35 | **/ios/**/*.pbxuser 36 | **/ios/**/*.perspectivev3 37 | **/ios/**/*sync/ 38 | **/ios/**/.sconsign.dblite 39 | **/ios/**/.tags* 40 | **/ios/**/.vagrant/ 41 | **/ios/**/DerivedData/ 42 | **/ios/**/Icon? 43 | **/ios/**/Pods/ 44 | **/ios/**/.symlinks/ 45 | **/ios/**/profile 46 | **/ios/**/xcuserdata 47 | **/ios/.generated/ 48 | **/ios/Flutter/.last_build_id 49 | **/ios/Flutter/ephemeral/ 50 | **/ios/Flutter/Flutter.podspec 51 | 52 | # Web 53 | **/web/favicon.png 54 | 55 | # IDE 56 | .idea/ 57 | .vscode/ 58 | *.iml 59 | *.iws 60 | .project 61 | .classpath 62 | .settings/ 63 | .vscode/ 64 | 65 | # Project specific 66 | .env 67 | .env.local 68 | *.env.json 69 | google-services.json 70 | GoogleService-Info.plist 71 | 72 | # Temporary files 73 | *.log.* 74 | *.bak 75 | *.tmp 76 | *~ 77 | .*.swp 78 | 79 | # Secrets and API Keys 80 | **/android/app/src/main/res/values/secrets.xml 81 | **/android/app/src/main/res/values/strings.xml 82 | **/android/local.properties 83 | **/android/app/src/main/res/values/api_keys.xml 84 | **/android/key.properties 85 | .env 86 | .env.local 87 | secrets.properties 88 | local.properties 89 | 90 | # iOS Secrets 91 | **/ios/Runner/Config.xcconfig 92 | **/ios/Runner/GoogleService-Info.plist 93 | **/ios/Flutter/Debug.xcconfig 94 | **/ios/Flutter/Release.xcconfig 95 | **/ios/Configuration.storekit 96 | **/ios/**/xcuserdata/ 97 | **/ios/.env.* 98 | **/ios/config/ 99 | **/ios/Runner/GeneratedPluginRegistrant.* 100 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | analyzer: 11 | plugins: 12 | - custom_lint 13 | errors: 14 | invalid_annotation_target: ignore 15 | void_checks: ignore 16 | include: package:flutter_lints/flutter.yaml 17 | 18 | linter: 19 | # The lint rules applied to this project can be customized in the 20 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 21 | # included above or to enable additional rules. A list of all available lints 22 | # and their documentation is published at https://dart.dev/lints. 23 | # 24 | # Instead of disabling a lint rule for the entire project in the 25 | # section below, it can also be suppressed for a single line of code 26 | # or a specific dart file by using the `// ignore: name_of_lint` and 27 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 28 | # producing the lint. 29 | rules: 30 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 31 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 32 | # Additional information about this file can be found at 33 | # https://dart.dev/guides/language/analysis-options 34 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/to/reference-keystore 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | // START: FlutterFire Configuration 4 | id 'com.google.gms.google-services' 5 | // END: FlutterFire Configuration 6 | id "kotlin-android" 7 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 8 | id "dev.flutter.flutter-gradle-plugin" 9 | } 10 | 11 | android { 12 | namespace "com.mrnpro.weyalaw" 13 | compileSdk 34 14 | ndkVersion = flutter.ndkVersion 15 | 16 | compileOptions { 17 | sourceCompatibility = JavaVersion.VERSION_1_8 18 | targetCompatibility = JavaVersion.VERSION_1_8 19 | } 20 | 21 | kotlinOptions { 22 | jvmTarget = JavaVersion.VERSION_1_8 23 | } 24 | 25 | defaultConfig { 26 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 27 | applicationId "com.mrnpro.weyalaw" 28 | // You can update the following values to match your application needs. 29 | // For more information, see: https://flutter.dev/to/review-gradle-config. 30 | minSdk 23 31 | targetSdk flutter.targetSdkVersion 32 | versionCode flutter.versionCode 33 | versionName flutter.versionName 34 | } 35 | 36 | signingConfigs { 37 | debug { 38 | storeFile file("debug.keystore") 39 | storePassword "android" 40 | keyAlias "androiddebugkey" 41 | keyPassword "android" 42 | } 43 | release { 44 | storeFile file("debug.keystore") 45 | storePassword "android" 46 | keyAlias "androiddebugkey" 47 | keyPassword "android" 48 | } 49 | 50 | } 51 | buildTypes { 52 | release { 53 | // TODO: Add your own signing config for the release build. 54 | // Signing with the debug keys for now, so `flutter run --release` works. 55 | signingConfig signingConfigs.release 56 | } 57 | debug { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source "../.." 67 | } 68 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/mrnpro/go_find_taxi/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mrnpro.weyalaw 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() 6 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:8.1.0' 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | google() 16 | mavenCentral() 17 | } 18 | } 19 | 20 | rootProject.buildDir = "../build" 21 | subprojects { 22 | project.buildDir = "${rootProject.buildDir}/${project.name}" 23 | } 24 | subprojects { 25 | project.evaluationDependsOn(":app") 26 | } 27 | 28 | tasks.register("clean", Delete) { 29 | delete rootProject.buildDir 30 | } 31 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version "7.3.0" apply false 22 | // START: FlutterFire Configuration 23 | id "com.google.gms.google-services" version "4.3.15" apply false 24 | // END: FlutterFire Configuration 25 | id "org.jetbrains.kotlin.android" version "1.9.0" apply false 26 | } 27 | 28 | include ":app" 29 | -------------------------------------------------------------------------------- /assets/animations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/assets/animations/.gitkeep -------------------------------------------------------------------------------- /assets/colors/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/assets/colors/.gitkeep -------------------------------------------------------------------------------- /assets/domain/.well-known/apple-app-site-association: -------------------------------------------------------------------------------- 1 | { 2 | "applinks": { 3 | "apps": [], 4 | "details": [ 5 | { 6 | "appID": "TEAM_ID.com.mrnpro.goFindTaxi", 7 | "components": [{ 8 | "/": "/share-my-location", 9 | "comment": "Matches any URL whose path starts with /share-my-location" 10 | }], 11 | "paths": [ "*" ] 12 | } 13 | ] 14 | }, 15 | "webcredentials": { 16 | "apps": ["TEAM_ID.com.mrnpro.goFindTaxi"] 17 | } 18 | } -------------------------------------------------------------------------------- /assets/domain/.well-known/assetlinks.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "relation": ["delegate_permission/common.handle_all_urls"], 4 | "target": { 5 | "namespace": "android_app", 6 | "package_name": "com.mrnpro.goFindTaxi", 7 | "sha256_cert_fingerprints": [ 8 | "FC:9D:9A:AC:3F:FC:B1:47:B1:C7:E8:01:80:AB:3B:C2:FB:28:AE:91:4A:65:D6:6B:68:A6:74:A0:3F:48:A4:4F" 9 | ] 10 | } 11 | } 12 | ] -------------------------------------------------------------------------------- /assets/icons/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/assets/icons/.gitkeep -------------------------------------------------------------------------------- /assets/images/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/assets/images/.gitkeep -------------------------------------------------------------------------------- /assets/images/location_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/assets/images/location_avatar.png -------------------------------------------------------------------------------- /assets/jsons/map_style.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/assets/jsons/map_style.json -------------------------------------------------------------------------------- /assets/svgs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/assets/svgs/.gitkeep -------------------------------------------------------------------------------- /assets/svgs/bus_icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /assets/svgs/bus_service.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /assets/svgs/filter.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /assets/svgs/home.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /assets/svgs/location.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /assets/svgs/map.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /assets/svgs/navigate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /assets/svgs/profile.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /assets/svgs/route_progress.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /assets/svgs/route_progress_vertical.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /assets/svgs/taxi_service.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | {"flutter":{"platforms":{"android":{"default":{"projectId":"bus-tracking-9d873","appId":"1:341778370735:android:4ba300a5525281ea87445a","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"bus-tracking-9d873","appId":"1:341778370735:ios:7cf28b3ac66e49bb87445a","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"bus-tracking-9d873","configurations":{"android":"1:341778370735:android:4ba300a5525281ea87445a","ios":"1:341778370735:ios:7cf28b3ac66e49bb87445a"}}}}}} -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter/Dart specific 2 | **/dgph 3 | .dart_tool/ 4 | .flutter-plugins 5 | .flutter-plugins-dependencies 6 | .packages 7 | .pub-cache/ 8 | .pub/ 9 | build/ 10 | flutter_*.png 11 | linked_*.ds 12 | unlinked.ds 13 | unlinked_spec.ds 14 | 15 | # iOS specific 16 | *.mode1v3 17 | *.mode2v3 18 | *.moved-aside 19 | *.pbxuser 20 | *.perspectivev3 21 | **/*sync/ 22 | .sconsign.dblite 23 | .tags* 24 | **/.vagrant/ 25 | **/DerivedData/ 26 | Icon? 27 | **/Pods/ 28 | **/.symlinks/ 29 | profile 30 | xcuserdata 31 | **/.generated/ 32 | Flutter/App.framework 33 | Flutter/Flutter.framework 34 | Flutter/Flutter.podspec 35 | Flutter/Generated.xcconfig 36 | Flutter/ephemeral/ 37 | Flutter/app.flx 38 | Flutter/app.zip 39 | Flutter/flutter_assets/ 40 | Flutter/flutter_export_environment.sh 41 | ServiceDefinitions.json 42 | Runner/GeneratedPluginRegistrant.* 43 | 44 | # macOS specific 45 | .DS_Store 46 | .AppleDouble 47 | .LSOverride 48 | ._* 49 | 50 | # Xcode 51 | *.xcodeproj/* 52 | !*.xcodeproj/project.pbxproj 53 | !*.xcodeproj/xcshareddata/ 54 | !*.xcodeproj/project.xcworkspace/ 55 | *.xcworkspace/ 56 | !*.xcworkspace/contents.xcworkspacedata 57 | **/xcshareddata/WorkspaceSettings.xcsettings 58 | 59 | # Exceptions to above rules 60 | !default.mode1v3 61 | !default.mode2v3 62 | !default.pbxuser 63 | !default.perspectivev3 64 | 65 | # IDE specific 66 | .idea/ 67 | .vscode/ 68 | *.iml 69 | *.iws 70 | .project 71 | .classpath 72 | .settings/ 73 | 74 | # Temporary files 75 | *.log 76 | *.swp 77 | .*.swp 78 | *~ 79 | -------------------------------------------------------------------------------- /ios/Config.xcconfig: -------------------------------------------------------------------------------- 1 | // Configuration settings file format documentation can be found at: 2 | // https://help.apple.com/xcode/#/dev745c5c974 3 | 4 | GOOGLE_MAPS_API_KEY=AIzaSyBRJd7Jbzg4OO2W4BNMLYjkCjW6QObULak -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | platform :ios, '14.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import GoogleMaps 4 | 5 | @main 6 | @objc class AppDelegate: FlutterAppDelegate { 7 | override func application( 8 | _ application: UIApplication, 9 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 10 | ) -> Bool { 11 | if let apiKey = Bundle.main.object(forInfoDictionaryKey: "GOOGLE_MAPS_API_KEY") as? String { 12 | GMSServices.provideAPIKey(apiKey) 13 | } else { 14 | print("Error: Google Maps API key not found in Info.plist") 15 | return false 16 | } 17 | 18 | GeneratedPluginRegistrant.register(with: self) 19 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 20 | } 21 | } -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Config.xcconfig.template: -------------------------------------------------------------------------------- 1 | // Configuration settings file format documentation can be found at: 2 | // https://help.apple.com/xcode/#/dev745c5c974 3 | 4 | GOOGLE_MAPS_API_KEY=your_google_maps_api_key_here -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSLocationWhenInUseUsageDescription 6 | This app requires access to your location to provide location-based services. 7 | NSLocationAlwaysUsageDescription 8 | This app requires access to your location at all times for better service. 9 | NSLocationUsageDescription 10 | This app requires access to your location to provide location-based services. 11 | CFBundleDevelopmentRegion 12 | $(DEVELOPMENT_LANGUAGE) 13 | CFBundleDisplayName 14 | Weyalaw 15 | CFBundleExecutable 16 | $(EXECUTABLE_NAME) 17 | CFBundleIdentifier 18 | $(PRODUCT_BUNDLE_IDENTIFIER) 19 | CFBundleInfoDictionaryVersion 20 | 6.0 21 | CFBundleName 22 | weyalaw 23 | CFBundlePackageType 24 | APPL 25 | CFBundleShortVersionString 26 | $(FLUTTER_BUILD_NAME) 27 | CFBundleSignature 28 | ???? 29 | CFBundleVersion 30 | $(FLUTTER_BUILD_NUMBER) 31 | LSRequiresIPhoneOS 32 | 33 | UILaunchStoryboardName 34 | LaunchScreen 35 | UIMainStoryboardFile 36 | Main 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | CADisableMinimumFrameDurationOnPhone 51 | 52 | UIApplicationSupportsIndirectInputEvents 53 | 54 | FlutterDeepLinkingEnabled 55 | 56 | GOOGLE_MAPS_API_KEY 57 | $(GOOGLE_MAPS_API_KEY) 58 | 59 | 60 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /ios/Runner/Runner.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /lib/_shared/data/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/lib/_shared/data/models/.gitkeep -------------------------------------------------------------------------------- /lib/_shared/data/repo/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/lib/_shared/data/repo/.gitkeep -------------------------------------------------------------------------------- /lib/_shared/presentation/dialog/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/lib/_shared/presentation/dialog/.gitkeep -------------------------------------------------------------------------------- /lib/_shared/presentation/provider/base_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | 4 | class BaseNotifier extends StateNotifier { 5 | BaseNotifier() : super(BaseState()); 6 | 7 | CancelToken cancelToken = CancelToken(); 8 | 9 | void setLoading(bool isLoading) { 10 | state = state.copyWith(isLoading: isLoading); 11 | } 12 | 13 | bool get isLoading => state.isLoading; 14 | } 15 | 16 | class BaseState { 17 | final bool isLoading; 18 | 19 | BaseState({this.isLoading = false}); 20 | 21 | BaseState copyWith({bool? isLoading}) { 22 | return BaseState( 23 | isLoading: isLoading ?? this.isLoading, 24 | ); 25 | } 26 | } 27 | 28 | final baseNotifierProvider = 29 | StateNotifierProvider((ref) { 30 | return BaseNotifier(); 31 | }); 32 | -------------------------------------------------------------------------------- /lib/_shared/presentation/screens/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/lib/_shared/presentation/screens/.gitkeep -------------------------------------------------------------------------------- /lib/_shared/presentation/screens/error_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../../core/utils/src/print_util.dart'; 4 | 5 | class ErrorScreen extends StatelessWidget { 6 | final Exception? error; 7 | 8 | const ErrorScreen(this.error, {super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | printLog("ErrorScreen: ${error?.toString()}"); 13 | return const Scaffold( 14 | body: Center( 15 | child: Text( 16 | '404', 17 | style: TextStyle( 18 | fontSize: 48, 19 | fontWeight: FontWeight.bold, 20 | ), 21 | ), 22 | ), 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/_shared/presentation/widgets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/lib/_shared/presentation/widgets/.gitkeep -------------------------------------------------------------------------------- /lib/_shared/presentation/widgets/app_container.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class AppContainer extends StatelessWidget { 4 | const AppContainer({ 5 | super.key, 6 | required this.child, 7 | this.width, 8 | this.height, 9 | this.padding, 10 | this.margin, 11 | this.color, 12 | this.radius, 13 | this.isShadow = true, 14 | }); 15 | final double? width; 16 | final double? height; 17 | final EdgeInsetsGeometry? padding; 18 | final EdgeInsetsGeometry? margin; 19 | final Widget child; 20 | final Color? color; 21 | final double? radius; 22 | final bool isShadow; 23 | @override 24 | Widget build(BuildContext context) { 25 | return Container( 26 | width: width, 27 | height: height, 28 | padding: 29 | padding ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 12), 30 | margin: margin, 31 | decoration: BoxDecoration( 32 | color: color ?? Colors.white, 33 | borderRadius: BorderRadius.circular(radius ?? 12), 34 | boxShadow: isShadow 35 | ? [ 36 | BoxShadow( 37 | color: Colors.grey.withOpacity(0.3), 38 | spreadRadius: 7, 39 | blurRadius: 10, 40 | offset: const Offset(0, 4), 41 | ), 42 | ] 43 | : null, 44 | ), 45 | child: child, 46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/_shared/presentation/widgets/back_btn.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:go_router/go_router.dart'; 3 | 4 | class BackBtn extends StatelessWidget { 5 | const BackBtn({ 6 | super.key, 7 | }); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return IconButton.filled( 12 | style: IconButton.styleFrom( 13 | backgroundColor: Colors.white, 14 | foregroundColor: Colors.black, 15 | ), 16 | onPressed: () { 17 | context.pop(); 18 | }, 19 | icon: const Icon(Icons.arrow_back)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/_shared/presentation/widgets/border_less_text_field.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class BorderLessTextField extends StatelessWidget { 4 | const BorderLessTextField( 5 | {super.key, 6 | this.onChanged, 7 | required this.hintText, 8 | required this.controller, 9 | required this.label}); 10 | 11 | final String hintText; 12 | final TextEditingController controller; 13 | final String label; 14 | 15 | final Function(String value)? onChanged; 16 | @override 17 | Widget build(BuildContext context) { 18 | return Column( 19 | crossAxisAlignment: CrossAxisAlignment.start, 20 | children: [ 21 | Text(label, 22 | style: TextStyle( 23 | color: const Color(0xFF000000).withOpacity(0.5), 24 | fontSize: 15, 25 | fontWeight: FontWeight.bold, 26 | )), 27 | SizedBox( 28 | width: 300, 29 | child: TextField( 30 | controller: controller, 31 | onChanged: onChanged, 32 | decoration: InputDecoration( 33 | isDense: true, 34 | contentPadding: EdgeInsets.zero, 35 | hintText: hintText, 36 | border: InputBorder.none, 37 | fillColor: Colors.transparent, 38 | filled: true, 39 | ), 40 | ), 41 | ), 42 | ], 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/_shared/presentation/widgets/navigation.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_svg/svg.dart'; 3 | import 'package:weyalaw/core/config/theme/color_pallete.dart'; 4 | import 'package:weyalaw/core/constants/assets.dart'; 5 | import 'package:go_router/go_router.dart'; 6 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 7 | 8 | class AppBottomNavigation extends HookConsumerWidget { 9 | const AppBottomNavigation({ 10 | Key? key, 11 | required this.navigationShell, 12 | }) : super(key: key ?? const ValueKey('AppBottomNavigation')); 13 | final StatefulNavigationShell navigationShell; 14 | 15 | void _goBranch(int index) { 16 | navigationShell.goBranch( 17 | index, 18 | initialLocation: index == navigationShell.currentIndex, 19 | ); 20 | } 21 | 22 | @override 23 | Widget build(BuildContext context, WidgetRef ref) { 24 | return Scaffold( 25 | body: navigationShell, 26 | bottomNavigationBar: Container( 27 | height: 80, 28 | decoration: BoxDecoration( 29 | color: Colors.white, 30 | borderRadius: BorderRadius.circular(16), 31 | ), 32 | child: NavigationBar( 33 | backgroundColor: Colors.transparent, 34 | selectedIndex: navigationShell.currentIndex, 35 | labelBehavior: NavigationDestinationLabelBehavior.alwaysHide, 36 | indicatorColor: Colors.transparent, 37 | destinations: [ 38 | ...navigationIcons.map((e) { 39 | final index = navigationIcons.indexOf(e); 40 | final isSelected = navigationShell.currentIndex == index; 41 | return NavigationDestination( 42 | label: e.label, 43 | icon: SvgPicture.asset(e.icon, 44 | colorFilter: ColorFilter.mode( 45 | isSelected ? ColorPalette.primary : Colors.black, 46 | BlendMode.srcIn)), 47 | ); 48 | }), 49 | ], 50 | onDestinationSelected: _goBranch, 51 | ), 52 | ), 53 | ); 54 | } 55 | } 56 | 57 | final List<({String label, String icon})> navigationIcons = [ 58 | (label: 'Home', icon: Assets.assetsSvgsHome), 59 | (label: 'Bus', icon: Assets.assetsSvgsBusIcon), 60 | (label: 'Profile', icon: Assets.assetsSvgsProfile), 61 | ]; 62 | -------------------------------------------------------------------------------- /lib/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | 4 | import 'core/config/router/router.dart'; 5 | import 'core/config/theme/theme_config.dart'; 6 | 7 | class App extends ConsumerWidget { 8 | const App({super.key}); 9 | @override 10 | Widget build(BuildContext context, WidgetRef ref) { 11 | final router = ref.watch(routerProvider); 12 | final theme = ref.watch(themeProvider); 13 | return MaterialApp.router( 14 | theme: theme, 15 | routeInformationProvider: router.routeInformationProvider, 16 | routeInformationParser: router.routeInformationParser, 17 | routerDelegate: router.routerDelegate, 18 | title: "Weyalaw", 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/core/analytics/observers/observers.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:weyalaw/core/utils/index.dart'; 3 | 4 | class NavigatorObserverAnalytics extends NavigatorObserver { 5 | @override 6 | void didPush(Route route, Route? previousRoute) { 7 | printLog('did push route'); 8 | } 9 | 10 | @override 11 | void didPop(Route route, Route? previousRoute) { 12 | printLog('did pop'); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/core/analytics/observers/riverpod_loger.dart: -------------------------------------------------------------------------------- 1 | import 'package:weyalaw/core/utils/index.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | class RiverpodLogger extends ProviderObserver { 5 | @override 6 | void didDisposeProvider( 7 | ProviderBase provider, ProviderContainer container) { 8 | printLog(''' 9 | { 10 | "provider": "${provider.name ?? provider.runtimeType}" 11 | }'''); 12 | super.didDisposeProvider(provider, container); 13 | } 14 | 15 | @override 16 | void didUpdateProvider( 17 | ProviderBase provider, 18 | Object? previousValue, 19 | Object? newValue, 20 | ProviderContainer container, 21 | ) { 22 | printLog(''' 23 | { 24 | "provider": "${provider.name ?? provider.runtimeType}", 25 | "newValue": "$newValue" 26 | }'''); 27 | super.didUpdateProvider(provider, previousValue, newValue, container); 28 | } 29 | 30 | @override 31 | void providerDidFail( 32 | ProviderBase provider, 33 | Object error, 34 | StackTrace stackTrace, 35 | ProviderContainer container, 36 | ) { 37 | printError(''' 38 | { 39 | "provider": "${provider.name ?? provider.runtimeType}", 40 | "error": "$error", 41 | "stackTrace": "$stackTrace" 42 | }'''); 43 | super.providerDidFail(provider, error, stackTrace, container); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/core/barrels/all_screens_barrel.dart: -------------------------------------------------------------------------------- 1 | // This file exports all screens from different modules 2 | export '../../modules/transit/presentation/pages/pages.dart'; 3 | -------------------------------------------------------------------------------- /lib/core/config/api/api_endpoints.dart: -------------------------------------------------------------------------------- 1 | class APIEndpoints { 2 | static const String baseUrl = "https://go-find-taxi-backend.onrender.com"; 3 | static const String redatBaseUrl = "https://redat-backend-production.up.railway.app"; 4 | 5 | // Redat endpoints 6 | static const String redatRouteMap = "/route-map"; 7 | 8 | // Main app endpoints 9 | static const String transportOptions = "/api/transport-options"; 10 | 11 | static const String directions = "/api/location/directions"; 12 | static const String geocode = "/api/location/geocode"; 13 | static const String reverseGeocode = "/api/location/reverse-geocode"; 14 | static const String placeName = "/api/location/place-name"; 15 | } 16 | -------------------------------------------------------------------------------- /lib/core/config/router/redirection.dart: -------------------------------------------------------------------------------- 1 | part of 'router.dart'; 2 | 3 | typedef GoRouterRedirect = Future; 4 | Future isAuthenticated() async { 5 | try { 6 | // final user = 7 | // await container.read(authRepoLocalProviderProvider).getCurrentUser(); 8 | // if (user.jwtToken != null) { 9 | // return true; 10 | // } 11 | return true; 12 | } catch (e) { 13 | return false; 14 | } 15 | } 16 | 17 | GoRouterRedirect goRouterRedirect( 18 | BuildContext context, GoRouterState state) async { 19 | return null; 20 | // Check if the user is going to the login page 21 | final loggingIn = state.matchedLocation == '/login'; 22 | final verifyingOtp = state.matchedLocation == '/verify-otp'; 23 | 24 | if (verifyingOtp) { 25 | return null; 26 | } 27 | final authenticated = await isAuthenticated(); 28 | // If the user is not logged in and not going to the login page, redirect to login 29 | if (!authenticated && !loggingIn) { 30 | return '/login'; 31 | } 32 | 33 | // If the user is logged in and going to login page, redirect to home 34 | if (authenticated && loggingIn) { 35 | return '/'; 36 | } 37 | 38 | // No redirection needed 39 | return null; 40 | } 41 | -------------------------------------------------------------------------------- /lib/core/config/router/route_name.dart: -------------------------------------------------------------------------------- 1 | class RouteName { 2 | static const String home = '/home'; 3 | static const String transitOverview = '/transit-overview'; 4 | static const String search = '/search-screen'; 5 | static const String seeAllTransportRoute = '/see-all-transport-route'; 6 | static const String startNavigation = '/start-navigation'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/core/config/theme/color_pallete.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class ColorPalette { 4 | static const Color primary = Color(0xFF0082FF); 5 | static const Color secondary = Color(0xFF334BC3); 6 | static const Color grey = Color(0xFF808080); 7 | } 8 | -------------------------------------------------------------------------------- /lib/core/config/theme/theme_config.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:weyalaw/core/utils/index.dart'; 4 | 5 | final themeProvider = StateNotifierProvider((ref) { 6 | return ThemeNotifier(); 7 | }); 8 | 9 | class ThemeNotifier extends StateNotifier { 10 | ThemeNotifier() : super(_lightTheme); 11 | 12 | static final _lightTheme = ThemeData( 13 | scaffoldBackgroundColor: HexColor('#EDEDED'), 14 | colorScheme: ColorScheme.fromSeed(seedColor: HexColor('#0082FF')), 15 | brightness: Brightness.light, 16 | ); 17 | 18 | static final _darkTheme = ThemeData( 19 | primarySwatch: Colors.indigo, 20 | brightness: Brightness.dark, 21 | ); 22 | 23 | void toggleTheme() { 24 | state = state.brightness == Brightness.light ? _darkTheme : _lightTheme; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/core/constants.dart: -------------------------------------------------------------------------------- 1 | const kDefaultPadding = 20.0; 2 | 3 | //// Keys 4 | const kLastUsedDestinationKey = "last_used_destination"; 5 | const kLastUsedOriginKey = "last_used_origin"; 6 | const currentLocationString = "Current Location"; 7 | -------------------------------------------------------------------------------- /lib/core/constants/assets.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: prefer_single_quotes 2 | class Assets { 3 | Assets._(); 4 | 5 | /// Assets for assetsImagesLocationAvatar 6 | /// assets/images/location_avatar.png 7 | static const String assetsImagesLocationAvatar = "assets/images/location_avatar.png"; 8 | 9 | /// Assets for assetsSvgsBusIcon 10 | /// assets/svgs/bus_icon.svg 11 | static const String assetsSvgsBusIcon = "assets/svgs/bus_icon.svg"; 12 | 13 | /// Assets for assetsSvgsBusService 14 | /// assets/svgs/bus_service.svg 15 | static const String assetsSvgsBusService = "assets/svgs/bus_service.svg"; 16 | 17 | /// Assets for assetsSvgsFilter 18 | /// assets/svgs/filter.svg 19 | static const String assetsSvgsFilter = "assets/svgs/filter.svg"; 20 | 21 | /// Assets for assetsSvgsHome 22 | /// assets/svgs/home.svg 23 | static const String assetsSvgsHome = "assets/svgs/home.svg"; 24 | 25 | /// Assets for assetsSvgsLocation 26 | /// assets/svgs/location.svg 27 | static const String assetsSvgsLocation = "assets/svgs/location.svg"; 28 | 29 | /// Assets for assetsSvgsMap 30 | /// assets/svgs/map.svg 31 | static const String assetsSvgsMap = "assets/svgs/map.svg"; 32 | 33 | /// Assets for assetsSvgsNavigate 34 | /// assets/svgs/navigate.svg 35 | static const String assetsSvgsNavigate = "assets/svgs/navigate.svg"; 36 | 37 | /// Assets for assetsSvgsProfile 38 | /// assets/svgs/profile.svg 39 | static const String assetsSvgsProfile = "assets/svgs/profile.svg"; 40 | 41 | /// Assets for assetsSvgsRouteProgress 42 | /// assets/svgs/route_progress.svg 43 | static const String assetsSvgsRouteProgress = "assets/svgs/route_progress.svg"; 44 | 45 | /// Assets for assetsSvgsRouteProgressVertical 46 | /// assets/svgs/route_progress_vertical.svg 47 | static const String assetsSvgsRouteProgressVertical = "assets/svgs/route_progress_vertical.svg"; 48 | 49 | /// Assets for assetsSvgsTaxiService 50 | /// assets/svgs/taxi_service.svg 51 | static const String assetsSvgsTaxiService = "assets/svgs/taxi_service.svg"; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /lib/core/extentions/app_shimmer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_animate/flutter_animate.dart'; 3 | 4 | extension ShimmerExtension on Widget { 5 | Widget appShimmer({ 6 | Color? baseColor, 7 | Color? highlightColor, 8 | Duration? period, 9 | }) { 10 | return animate(onPlay: (controller) => controller.repeat()) 11 | .shimmer(duration: 1200.ms, color: Colors.white) 12 | .animate() 13 | .fadeIn(duration: 1200.ms, curve: Curves.easeOutQuad); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/core/extentions/date_extention.dart: -------------------------------------------------------------------------------- 1 | import 'package:intl/intl.dart'; 2 | 3 | extension DateX on DateTime { 4 | String formatDate() { 5 | return DateFormat('MMM dd, yyyy').format(this); 6 | } 7 | 8 | String timeRemainingInFourMonths() { 9 | final now = DateTime.now(); 10 | final fourMonthsLater = add(const Duration(days: 120)); 11 | final difference = fourMonthsLater.difference(now); 12 | 13 | final int days = difference.inDays; 14 | 15 | if (days >= 30) { 16 | final int months = days ~/ 30; 17 | return '$months month${months > 1 ? 's' : ''}'; 18 | } else { 19 | return '$days day${days > 1 ? 's' : ''}'; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/core/handlers/dio_error_handler.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | class DioErrorHandler { 4 | static String handleError(DioException error) { 5 | switch (error.type) { 6 | case DioExceptionType.sendTimeout: 7 | return 'Send request timed out. Please try again.'; 8 | case DioExceptionType.receiveTimeout: 9 | return 'Receive timed out. Please try again.'; 10 | case DioExceptionType.badResponse: 11 | return _handleResponseError(error.response); 12 | case DioExceptionType.cancel: 13 | return 'Request to the server was cancelled.'; 14 | case DioExceptionType.unknown: 15 | return 'Something went wrong. Please check your connection.'; 16 | case DioExceptionType.connectionError: 17 | return 'Something went wrong. Please check your connection.'; 18 | 19 | default: 20 | return 'An unexpected error occurred.'; 21 | } 22 | } 23 | 24 | static String _handleResponseError(Response? response) { 25 | if (response == null) { 26 | return 'No response from the server. Please try again.'; 27 | } 28 | 29 | switch (response.statusCode) { 30 | case 400: 31 | return 'Bad request.'; 32 | case 401: 33 | return 'Unauthorized. Please check your credentials.'; 34 | case 403: 35 | return 'Access forbidden. You do not have permission.'; 36 | case 404: 37 | return 'Resource not found. Please try again.'; 38 | case 500: 39 | return 'Internal server error. Please try later.'; 40 | case 503: 41 | return 'Service unavailable. Please try later.'; 42 | default: 43 | return 'Received an unexpected error: ${response.statusCode}.'; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/core/handlers/error_handler.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | import 'dio_error_handler.dart'; 4 | 5 | class ErrorHandler { 6 | static String handleError(dynamic error) { 7 | if (error is DioException) { 8 | return DioErrorHandler.handleError(error); 9 | } else if (error is Exception) { 10 | return 'An unexpected error occurred'; 11 | } 12 | return 'Something went wrong'; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/core/handlers/failure/failure.dart: -------------------------------------------------------------------------------- 1 | import 'package:weyalaw/core/handlers/error_handler.dart'; 2 | 3 | import '../result.dart'; 4 | 5 | class Failure { 6 | final String? message; 7 | final String? stackTrace; 8 | 9 | Failure({required this.message, this.stackTrace}); 10 | 11 | static Result send({required Object error}) { 12 | final message = ErrorHandler.handleError(error); 13 | return result(Failure(message: message)); 14 | } 15 | 16 | @override 17 | bool operator ==(Object other) { 18 | if (identical(this, other)) return true; 19 | return other is Failure && 20 | other.message == message && 21 | other.stackTrace == stackTrace; 22 | } 23 | 24 | @override 25 | int get hashCode => message.hashCode ^ stackTrace.hashCode; 26 | } 27 | -------------------------------------------------------------------------------- /lib/core/handlers/result.dart: -------------------------------------------------------------------------------- 1 | /// This file contains type definitions and utility functions for handling 2 | /// success and failure results in a type-safe manner. 3 | library; 4 | 5 | import 'failure/failure.dart'; 6 | import 'success/success.dart'; 7 | 8 | /// Represents a result that can be either a success or a failure. 9 | typedef Result = ({Success? success, Failure? failure}); 10 | 11 | /// Represents a future result that can be either a success or a failure. 12 | typedef FutureResult = Future<({Success? success, Failure? failure})>; 13 | 14 | /// Creates a [Result] from a given value. 15 | /// 16 | /// If the value is a [Success], it returns a success result. 17 | /// If the value is a [Failure], it returns a failure result. 18 | /// For any other type, it returns a failure result with an "Unknown result type" message. 19 | Result result(dynamic result) { 20 | if (result is Success) { 21 | return (success: result as Success, failure: null); 22 | } else if (result is Failure) { 23 | return (success: null, failure: result); 24 | } else { 25 | return (success: null, failure: Failure(message: 'Unknown result type')); 26 | } 27 | } 28 | 29 | /// Creates a [FutureResult] from a given value. 30 | /// 31 | /// Similar to [result], but wraps the result in a [Future]. 32 | FutureResult futureResult(dynamic result) { 33 | if (result is Success) { 34 | return Future.value((success: result as Success, failure: null)); 35 | } else if (result is Failure) { 36 | return Future.value((success: null, failure: result)); 37 | } else { 38 | return Future.value( 39 | (success: null, failure: Failure(message: 'Unknown result type'))); 40 | } 41 | } 42 | 43 | /// Extension on [Result] to provide a fold operation. 44 | extension ResultExt on ({Failure? failure, Success? success}) { 45 | /// Applies [onSuccess] if the result is a success, or [onFailure] if it's a failure. 46 | /// 47 | /// Throws an exception if the result is neither success nor failure. 48 | R fold({ 49 | required R Function(Success) onSuccess, 50 | required R Function(Failure) onFailure, 51 | }) { 52 | final res = this; 53 | if (res.success != null) { 54 | return onSuccess(res.success!); 55 | } else if (res.failure != null) { 56 | return onFailure(res.failure!); 57 | } 58 | return onFailure(Failure(message: 'Result is neither success nor failure')); 59 | } 60 | } 61 | 62 | Result test() { 63 | try { 64 | return Success.send(data: 'Test success'); 65 | } catch (e) { 66 | return Failure.send(error: e); 67 | } 68 | } 69 | 70 | void main(List args) { 71 | final res = test(); 72 | if (res.failure != null) { 73 | print('Failure: ${res.failure!.message}'); 74 | } else { 75 | print('Success: ${res.success!.data}'); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/core/handlers/success/success.dart: -------------------------------------------------------------------------------- 1 | import '../result.dart'; 2 | 3 | class Unit { 4 | const Unit._internal(); 5 | @override 6 | String toString() => "()"; 7 | } 8 | 9 | const Unit unit = Unit._internal(); 10 | 11 | class Success { 12 | final T data; 13 | Success({required this.data}); 14 | 15 | static Result send({required T data}) => result(Success(data: data)); 16 | 17 | @override 18 | bool operator ==(Object other) { 19 | if (identical(this, other)) return true; 20 | return other is Success && other.data == data; 21 | } 22 | 23 | @override 24 | int get hashCode => data.hashCode; 25 | } 26 | -------------------------------------------------------------------------------- /lib/core/interceptors/dio_interceptor.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | import '../utils/index.dart'; 4 | import '../handlers/dio_error_handler.dart'; 5 | 6 | class DioInterceptor implements Interceptor { 7 | @override 8 | void onError(DioException err, ErrorInterceptorHandler handler) { 9 | final errorMessage = DioErrorHandler.handleError(err); 10 | 11 | final updatedError = DioException( 12 | requestOptions: err.requestOptions, 13 | response: err.response, 14 | type: err.type, 15 | error: err.error, 16 | message: errorMessage, 17 | ); 18 | 19 | printError('Error [${err.response?.statusCode}] => MESSAGE: $errorMessage'); 20 | 21 | handler.next(updatedError); 22 | } 23 | 24 | @override 25 | void onRequest(RequestOptions options, RequestInterceptorHandler handler) { 26 | handler.next(options); 27 | } 28 | 29 | @override 30 | void onResponse(Response response, ResponseInterceptorHandler handler) { 31 | handler.next(response); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/core/services/LocationService/from_server_impl.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'package:weyalaw/core/config/api/api_endpoints.dart'; 3 | import 'package:http/http.dart' as http; 4 | import 'package:weyalaw/core/services/LocationService/models/direction.dart'; 5 | import 'package:weyalaw/core/services/LocationService/models/geo_coding_response.dart'; 6 | import 'package:weyalaw/core/services/LocationService/models/reverse_geocoding_response.dart'; 7 | import 'package:google_maps_flutter_platform_interface/src/types/location.dart'; 8 | import 'location_service.dart'; 9 | 10 | class FromServerImpl extends LocationService { 11 | final String baseUrl = APIEndpoints.baseUrl; 12 | 13 | @override 14 | Future geDirection({ 15 | required LatLng origin, 16 | required LatLng destination, 17 | }) async { 18 | try { 19 | final url = Uri.parse( 20 | '$baseUrl${APIEndpoints.directions}?originLat=${origin.latitude}&originLng=${origin.longitude}' 21 | '&destLat=${destination.latitude}&destLng=${destination.longitude}', 22 | ); 23 | 24 | final response = await http.get(url); 25 | 26 | if (response.statusCode == 200) { 27 | final data = json.decode(response.body); 28 | return Direction.fromMap(data); 29 | } else { 30 | throw Exception('Failed to get directions: ${response.body}'); 31 | } 32 | } catch (e) { 33 | print('Error getting directions: $e'); 34 | return null; 35 | } 36 | } 37 | 38 | @override 39 | Future> geoCoding(String placeName) async { 40 | try { 41 | final url = Uri.parse( 42 | '$baseUrl${APIEndpoints.geocode}?placeName=${Uri.encodeComponent(placeName)}'); 43 | final response = await http.get(url); 44 | 45 | if (response.statusCode == 200) { 46 | final List data = json.decode(response.body); 47 | return data.map((e) => GeoCoding.fromJson(e)).toList(); 48 | } else { 49 | throw Exception('Failed to geocode: ${response.body}'); 50 | } 51 | } catch (e) { 52 | print('Error geocoding: $e'); 53 | return []; 54 | } 55 | } 56 | 57 | @override 58 | Future getPlaceNameByLatLng(LatLng latLng) async { 59 | try { 60 | final url = Uri.parse( 61 | '$baseUrl${APIEndpoints.placeName}?lat=${latLng.latitude}&lng=${latLng.longitude}', 62 | ); 63 | final response = await http.get(url); 64 | 65 | if (response.statusCode == 200) { 66 | final data = json.decode(response.body); 67 | return data['placeName'] ?? 'Unknown Place'; 68 | } else { 69 | throw Exception('Failed to get place name: ${response.body}'); 70 | } 71 | } catch (e) { 72 | print('Error getting place name: $e'); 73 | return 'Unknown Place'; 74 | } 75 | } 76 | 77 | @override 78 | Future> reverseGeoCoding(LatLng latLng) async { 79 | try { 80 | final url = Uri.parse( 81 | '$baseUrl${APIEndpoints.reverseGeocode}?lat=${latLng.latitude}&lng=${latLng.longitude}', 82 | ); 83 | final response = await http.get(url); 84 | 85 | if (response.statusCode == 200) { 86 | final List data = json.decode(response.body); 87 | return data.map((e) => ReverseGeocoding.fromJson(e)).toList(); 88 | } else { 89 | throw Exception('Failed to reverse geocode: ${response.body}'); 90 | } 91 | } catch (e) { 92 | print('Error reverse geocoding: $e'); 93 | return []; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /lib/core/services/LocationService/gebeta_maps_impl.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:weyalaw/core/services/LocationService/models/direction.dart'; 4 | import 'package:weyalaw/core/services/LocationService/models/geo_coding_response.dart'; 5 | import 'package:weyalaw/core/services/LocationService/models/reverse_geocoding_response.dart'; 6 | import 'package:weyalaw/core/utils/index.dart'; 7 | import 'package:google_maps_widget/google_maps_widget.dart'; 8 | import 'package:http/http.dart' as http; 9 | import 'location_service.dart'; 10 | import 'package:flutter_dotenv/flutter_dotenv.dart'; 11 | 12 | class GebetaMapsImpl extends LocationService { 13 | final String apiKey = dotenv.env['GEBETA_MAPS_API_KEY'] ?? ''; 14 | final String baseUrl = "https://mapapi.gebeta.app/api/v1/route"; 15 | @override 16 | Future geDirection( 17 | {required LatLng origin, required LatLng destination}) async { 18 | String lat1 = origin.latitude.toString(); 19 | String lon1 = origin.longitude.toString(); 20 | String lat2 = destination.latitude.toString(); 21 | String lon2 = destination.longitude.toString(); 22 | final baseUrl2 = baseUrl.replaceAll('/v1', ''); 23 | String url = 24 | "$baseUrl2/direction/?origin={$lat1,$lon1}&destination={$lat2,$lon2}&apiKey=$apiKey"; 25 | 26 | try { 27 | final response = await http.get(Uri.parse(url)); 28 | 29 | if (response.statusCode == 200) { 30 | var data = json.decode(response.body); 31 | print(data); 32 | return Direction.fromMap(data); 33 | } else { 34 | throw Exception('Error: ${response.body}'); 35 | } 36 | } catch (e) { 37 | printError('An error occurred: $e'); 38 | rethrow; 39 | } 40 | } 41 | 42 | @override 43 | Future> geoCoding(String placeName) async { 44 | try { 45 | String url = "$baseUrl/geocoding?name=$placeName&apiKey=$apiKey"; 46 | final response = await http.get(Uri.parse(url)); 47 | 48 | if (response.statusCode == 200) { 49 | var decoded = json.decode(response.body); 50 | final data = decoded['data']; 51 | final geoCoding = []; 52 | for (var e in data) { 53 | geoCoding.add(GeoCoding.fromJson(e)); 54 | } 55 | return geoCoding; 56 | } else { 57 | throw Exception('Error: ${response.body}'); 58 | } 59 | } catch (e) { 60 | printError('Error getting geo coding: $e'); 61 | rethrow; 62 | } 63 | } 64 | 65 | @override 66 | Future> reverseGeoCoding(LatLng latLng) async { 67 | try { 68 | String url = 69 | "$baseUrl/revgeocoding?lat=${latLng.latitude}&lon=${latLng.longitude}&apiKey=$apiKey"; 70 | 71 | final response = await http.get(Uri.parse(url)); 72 | 73 | if (response.statusCode == 200) { 74 | var data = json.decode(response.body); 75 | print(data); 76 | final List reverseGeoCodeing = []; 77 | print(reverseGeoCodeing); 78 | for (var element in data['data']) { 79 | reverseGeoCodeing.add(ReverseGeocoding.fromJson(element)); 80 | } 81 | return reverseGeoCodeing; 82 | } else { 83 | throw Exception('Error: ${response.body}'); 84 | } 85 | } catch (e) { 86 | printError('Error getting reverse geocoding: $e'); 87 | rethrow; 88 | } 89 | } 90 | 91 | @override 92 | Future getPlaceNameByLatLng(LatLng latLng) async { 93 | try { 94 | final rvCodings = await reverseGeoCoding(latLng); 95 | return rvCodings.firstOrNull?.name ?? "Unknown Place"; 96 | } catch (e) { 97 | rethrow; 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /lib/core/services/LocationService/google_map_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:weyalaw/core/services/LocationService/location_service.dart'; 2 | import 'package:weyalaw/core/services/LocationService/models/direction.dart'; 3 | import 'package:weyalaw/core/services/LocationService/models/geo_coding_response.dart'; 4 | import 'package:weyalaw/core/services/LocationService/models/reverse_geocoding_response.dart'; 5 | import 'package:google_maps_flutter_platform_interface/src/types/location.dart'; 6 | 7 | class GoogleMapImpl extends LocationService { 8 | @override 9 | Future geDirection( 10 | {required LatLng origin, required LatLng destination}) { 11 | // TODO: implement geDirection 12 | throw UnimplementedError(); 13 | } 14 | 15 | @override 16 | Future> geoCoding(String placeName) { 17 | // TODO: implement geoCoding 18 | throw UnimplementedError(); 19 | } 20 | 21 | @override 22 | Future getCurrentLocation() { 23 | // TODO: implement getCurrentLocation 24 | throw UnimplementedError(); 25 | } 26 | 27 | @override 28 | Future getPlaceNameByLatLng(LatLng latLng) { 29 | // TODO: implement getPlaceNameByLatLng 30 | throw UnimplementedError(); 31 | } 32 | 33 | @override 34 | Future> reverseGeoCoding(LatLng latLng) { 35 | // TODO: implement reverseGeoCoding 36 | throw UnimplementedError(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/core/services/LocationService/models/direction.dart: -------------------------------------------------------------------------------- 1 | import 'package:google_maps_widget/google_maps_widget.dart'; 2 | 3 | class Direction { 4 | const Direction({ 5 | required this.polylinePoints, 6 | required this.totalDistance, 7 | required this.totalDuration, 8 | }); 9 | 10 | /// to display the route. 11 | final List polylinePoints; 12 | 13 | /// The total distance between the source and the destination. 14 | final String totalDistance; 15 | 16 | /// The total time between the source and the destination. 17 | final String totalDuration; 18 | 19 | /// Private constructor for [Direction] which receives a map from the 20 | /// api request and maps the response to the class variables. 21 | factory Direction.fromMap(Map map) { 22 | // Get route information 23 | final data = map; 24 | 25 | // Create list of LatLng points from direction array 26 | final List points = []; 27 | for (var point in data['direction']) { 28 | points.add(LatLng(point[0], point[1])); 29 | } 30 | 31 | return Direction( 32 | polylinePoints: points, 33 | totalDistance: data['totalDistance'].toString(), 34 | totalDuration: data['timetaken'].toString(), 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/core/services/LocationService/models/geo_coding_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:freezed_annotation/freezed_annotation.dart'; 2 | 3 | part 'geo_coding_response.freezed.dart'; 4 | part 'geo_coding_response.g.dart'; 5 | 6 | @freezed 7 | class GeoCoding with _$GeoCoding { 8 | const factory GeoCoding({ 9 | required num? latitude, 10 | required num? longitude, 11 | required String? name, 12 | required String? city, 13 | required String? country, 14 | required String? type, 15 | }) = _GeoCoding; 16 | 17 | factory GeoCoding.fromJson(Map json) => 18 | _$GeoCodingFromJson(json); 19 | } 20 | -------------------------------------------------------------------------------- /lib/core/services/LocationService/models/geo_coding_response.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'geo_coding_response.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _$GeoCodingImpl _$$GeoCodingImplFromJson(Map json) => 10 | _$GeoCodingImpl( 11 | latitude: json['latitude'] as num?, 12 | longitude: json['longitude'] as num?, 13 | name: json['name'] as String?, 14 | city: json['city'] as String?, 15 | country: json['country'] as String?, 16 | type: json['type'] as String?, 17 | ); 18 | 19 | Map _$$GeoCodingImplToJson(_$GeoCodingImpl instance) => 20 | { 21 | 'latitude': instance.latitude, 22 | 'longitude': instance.longitude, 23 | 'name': instance.name, 24 | 'city': instance.city, 25 | 'country': instance.country, 26 | 'type': instance.type, 27 | }; 28 | -------------------------------------------------------------------------------- /lib/core/services/LocationService/models/reverse_geocoding_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:freezed_annotation/freezed_annotation.dart'; 2 | 3 | part 'reverse_geocoding_response.freezed.dart'; 4 | part 'reverse_geocoding_response.g.dart'; 5 | 6 | @freezed 7 | class ReverseGeocoding with _$ReverseGeocoding { 8 | const factory ReverseGeocoding({ 9 | required String? name, 10 | required double? latitude, 11 | required double? longitude, 12 | @JsonKey(name: 'Country') required String? country, 13 | @JsonKey(name: 'City') required String? city, 14 | required String type, 15 | required double? duration, 16 | required double? distance, 17 | }) = _ReverseGeocoding; 18 | 19 | factory ReverseGeocoding.fromJson(Map json) => 20 | _$ReverseGeocodingFromJson(json); 21 | } 22 | -------------------------------------------------------------------------------- /lib/core/services/LocationService/models/reverse_geocoding_response.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'reverse_geocoding_response.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _$ReverseGeocodingImpl _$$ReverseGeocodingImplFromJson( 10 | Map json) => 11 | _$ReverseGeocodingImpl( 12 | name: json['name'] as String?, 13 | latitude: (json['latitude'] as num?)?.toDouble(), 14 | longitude: (json['longitude'] as num?)?.toDouble(), 15 | country: json['Country'] as String?, 16 | city: json['City'] as String?, 17 | type: json['type'] as String, 18 | duration: (json['duration'] as num?)?.toDouble(), 19 | distance: (json['distance'] as num?)?.toDouble(), 20 | ); 21 | 22 | Map _$$ReverseGeocodingImplToJson( 23 | _$ReverseGeocodingImpl instance) => 24 | { 25 | 'name': instance.name, 26 | 'latitude': instance.latitude, 27 | 'longitude': instance.longitude, 28 | 'Country': instance.country, 29 | 'City': instance.city, 30 | 'type': instance.type, 31 | 'duration': instance.duration, 32 | 'distance': instance.distance, 33 | }; 34 | -------------------------------------------------------------------------------- /lib/core/services/OnlineService/httpService/http_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:riverpod_annotation/riverpod_annotation.dart'; 4 | part 'http_service.g.dart'; 5 | 6 | @riverpod 7 | HttpService httpService(Ref ref) { 8 | throw UnimplementedError(); 9 | } 10 | 11 | abstract class HttpService { 12 | void init(); 13 | 14 | Future getRequest({ 15 | required String urlPath, 16 | Map queryParam = const {}, 17 | Map header = const {}, 18 | }); 19 | 20 | Future postRequest({ 21 | required String urlPath, 22 | required Map data, 23 | Map queryParam = const {}, 24 | Map header = const {}, 25 | }); 26 | 27 | Future putRequest({ 28 | required String urlPath, 29 | required Map data, 30 | Map queryParam = const {}, 31 | }); 32 | 33 | Future deleteRequest({ 34 | required String urlPath, 35 | required Map data, 36 | Map queryParam = const {}, 37 | }); 38 | 39 | Future postFormDataRequest({ 40 | required String urlPath, 41 | required FormData formData, 42 | Map? rawData, 43 | Map queryParam = const {}, 44 | Map header = const {}, 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /lib/core/services/OnlineService/httpService/http_service.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'http_service.dart'; 4 | 5 | // ************************************************************************** 6 | // RiverpodGenerator 7 | // ************************************************************************** 8 | 9 | String _$httpServiceHash() => r'b66519b432532bced9d28a4ffdd115a37b65eeef'; 10 | 11 | /// See also [httpService]. 12 | @ProviderFor(httpService) 13 | final httpServiceProvider = AutoDisposeProvider.internal( 14 | httpService, 15 | name: r'httpServiceProvider', 16 | debugGetCreateSourceHash: 17 | const bool.fromEnvironment('dart.vm.product') ? null : _$httpServiceHash, 18 | dependencies: null, 19 | allTransitiveDependencies: null, 20 | ); 21 | 22 | @Deprecated('Will be removed in 3.0. Use Ref instead') 23 | // ignore: unused_element 24 | typedef HttpServiceRef = AutoDisposeProviderRef; 25 | // ignore_for_file: type=lint 26 | // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package 27 | -------------------------------------------------------------------------------- /lib/core/services/OnlineService/httpService/http_service_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:injectable/injectable.dart'; 4 | 5 | import '../../../interceptors/dio_interceptor.dart'; 6 | import '../../../utils/index.dart'; 7 | import '../../../config/api/api_endpoints.dart'; 8 | import 'http_service.dart'; 9 | 10 | @LazySingleton(as: HttpService) 11 | class HttpServiceImpl extends HttpService { 12 | late Dio _dio; 13 | 14 | HttpServiceImpl(); 15 | 16 | @override 17 | Future deleteRequest( 18 | {required String urlPath, 19 | required Map data, 20 | Map queryParam = const {}}) async { 21 | try { 22 | printLog(urlPath); 23 | return await _dio.delete(urlPath); 24 | } on DioException catch (_) { 25 | rethrow; 26 | } 27 | } 28 | 29 | @override 30 | Future getRequest( 31 | {required String urlPath, 32 | Map queryParam = const {}, 33 | Map header = const {}}) async { 34 | try { 35 | return await _dio.get(urlPath, 36 | queryParameters: queryParam, options: Options(headers: header)); 37 | } on DioException catch (_) { 38 | rethrow; 39 | } 40 | } 41 | 42 | @override 43 | Future postRequest( 44 | {required String urlPath, 45 | required Map data, 46 | Map queryParam = const {}, 47 | Map header = const {}}) async { 48 | try { 49 | if (kDebugMode) { 50 | print(data); 51 | } 52 | Response response = await _dio.post(urlPath, 53 | queryParameters: queryParam, 54 | data: data, 55 | options: Options(headers: header)); 56 | return response; 57 | } on DioException catch (_) { 58 | rethrow; 59 | } 60 | } 61 | 62 | @override 63 | Future putRequest( 64 | {required String urlPath, 65 | required Map data, 66 | Map queryParam = const {}}) async { 67 | try { 68 | if (kDebugMode) { 69 | print(data); 70 | } 71 | Response response = await _dio.put( 72 | urlPath, 73 | queryParameters: queryParam, 74 | data: data, 75 | ); 76 | return response; 77 | } on DioException catch (_) { 78 | rethrow; 79 | } 80 | } 81 | 82 | @override 83 | Future postFormDataRequest({ 84 | required String urlPath, 85 | required FormData formData, 86 | Map? rawData, 87 | Map queryParam = const {}, 88 | Map header = const {}, 89 | }) async { 90 | try { 91 | if (kDebugMode) { 92 | print(formData.fields); // Print form fields for debugging if needed 93 | } 94 | 95 | Response response = await _dio.post( 96 | urlPath, 97 | data: formData, 98 | ); 99 | return response; 100 | } on DioException catch (_) { 101 | rethrow; 102 | } 103 | } 104 | 105 | @override 106 | void init() { 107 | const timeOut = Duration(seconds: 60); 108 | _dio = Dio(BaseOptions( 109 | baseUrl: APIEndpoints.baseUrl, 110 | sendTimeout: timeOut, 111 | receiveTimeout: timeOut, 112 | connectTimeout: timeOut)); 113 | final interceptors = [DioInterceptor()]; 114 | _dio.interceptors.addAll(interceptors); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /lib/core/services/index.dart: -------------------------------------------------------------------------------- 1 | export 'launch_service.dart'; 2 | export 'OnlineService/httpService/http_service.dart'; 3 | export 'localService/local_service_provider.dart'; 4 | -------------------------------------------------------------------------------- /lib/core/services/launch_service.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: deprecated_member_use 2 | 3 | import 'dart:io'; 4 | 5 | import 'package:url_launcher/url_launcher.dart'; 6 | 7 | abstract class LaunchService { 8 | Future launchMaps(double lat, double lon); 9 | Future launchPhoneCall(String phoneNumber); 10 | 11 | Future launchWebsite(String url); 12 | } 13 | 14 | class LaunchServiceImpl implements LaunchService { 15 | @override 16 | Future launchMaps(double lat, double lon) async { 17 | String appleUrl = 18 | 'https://maps.apple.com/?saddr=&daddr=$lat,$lon&directionsmode=driving'; 19 | String googleUrl = 20 | 'https://www.google.com/maps/search/?api=1&query=$lat,$lon'; 21 | 22 | if (Platform.isIOS) { 23 | if (await canLaunchUrl(Uri.parse(appleUrl))) { 24 | await launch(appleUrl); 25 | } else { 26 | if (await canLaunchUrl(Uri.parse(googleUrl))) { 27 | await launch(googleUrl); 28 | } else { 29 | throw 'Could not open the map.'; 30 | } 31 | } 32 | } else { 33 | if (await canLaunch(googleUrl)) { 34 | await launch(googleUrl); 35 | } else { 36 | throw 'Could not open the map.'; 37 | } 38 | } 39 | } 40 | 41 | @override 42 | Future launchPhoneCall(String phoneNumber) async { 43 | final phoneUrl = 'tel:$phoneNumber'; 44 | await _launchUrl(phoneUrl); 45 | } 46 | 47 | @override 48 | Future launchWebsite(String url) async { 49 | await _launchUrl(url); 50 | } 51 | 52 | Future _launchUrl(String url) async { 53 | if (await canLaunchUrl(Uri.parse(url))) { 54 | await launch(url); 55 | } else { 56 | throw 'Could not launch $url'; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/core/services/localService/local_service.dart: -------------------------------------------------------------------------------- 1 | abstract class LocalStorageService { 2 | Future init(); 3 | Future isExists({required String key}); 4 | read({required String key}); 5 | Future write({required String key, required dynamic value}); 6 | Future delete({required String key, required dynamic data}); 7 | Future clear({required String key}); 8 | Future clearAll(); 9 | } 10 | -------------------------------------------------------------------------------- /lib/core/services/localService/local_service_impl.dart: -------------------------------------------------------------------------------- 1 | import 'package:hive_flutter/hive_flutter.dart'; 2 | 3 | import 'local_service.dart'; 4 | 5 | class HiveLocalStorageService extends LocalStorageService { 6 | late Box _box; 7 | 8 | @override 9 | Future init() async { 10 | await Hive.initFlutter(); 11 | _box = await Hive.openBox('local_storage_box'); 12 | } 13 | 14 | @override 15 | Future isExists({required String key}) async { 16 | return _box.containsKey(key); 17 | } 18 | 19 | @override 20 | dynamic read({required String key}) { 21 | return _box.get(key); 22 | } 23 | 24 | @override 25 | Future write({required String key, required dynamic value}) async { 26 | await _box.put(key, value); 27 | } 28 | 29 | @override 30 | Future clear({required String key}) async { 31 | await _box.delete(key); 32 | } 33 | 34 | @override 35 | Future clearAll() async { 36 | await _box.clear(); 37 | } 38 | 39 | @override 40 | Future delete({required String key, required data}) { 41 | try { 42 | throw UnimplementedError(); 43 | } catch (e) { 44 | rethrow; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/core/services/localService/local_service_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:riverpod_annotation/riverpod_annotation.dart'; 2 | 3 | import 'local_service.dart'; 4 | part 'local_service_provider.g.dart'; 5 | 6 | @Riverpod(keepAlive: true) 7 | LocalStorageService localStorageService(_) => throw UnimplementedError(); 8 | -------------------------------------------------------------------------------- /lib/core/services/localService/local_service_provider.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'local_service_provider.dart'; 4 | 5 | // ************************************************************************** 6 | // RiverpodGenerator 7 | // ************************************************************************** 8 | 9 | String _$localStorageServiceHash() => 10 | r'148a3959113cb87e91fd3688ee06b58a415d7925'; 11 | 12 | /// See also [localStorageService]. 13 | @ProviderFor(localStorageService) 14 | final localStorageServiceProvider = Provider.internal( 15 | localStorageService, 16 | name: r'localStorageServiceProvider', 17 | debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') 18 | ? null 19 | : _$localStorageServiceHash, 20 | dependencies: null, 21 | allTransitiveDependencies: null, 22 | ); 23 | 24 | @Deprecated('Will be removed in 3.0. Use Ref instead') 25 | // ignore: unused_element 26 | typedef LocalStorageServiceRef = ProviderRef; 27 | // ignore_for_file: type=lint 28 | // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package 29 | -------------------------------------------------------------------------------- /lib/core/utils/index.dart: -------------------------------------------------------------------------------- 1 | export 'src/color_utils.dart'; 2 | 3 | export 'src/debounce.dart'; 4 | export 'src/print_util.dart'; 5 | export 'src/date_util.dart'; 6 | export 'src/safe_ui_api_call.dart'; 7 | export 'src/leg_utils.dart'; 8 | -------------------------------------------------------------------------------- /lib/core/utils/src/calculate_distance.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | double calculateDistance( 4 | double latitude1, double longitude1, double latitude2, double longitude2) { 5 | const double earthRadius = 6371.0; // Earth's radius in kilometers 6 | 7 | final double dLat = _degreesToRadians(latitude2 - latitude1); 8 | final double dLon = _degreesToRadians(longitude2 - longitude1); 9 | 10 | final double a = (sin(dLat / 2) * sin(dLat / 2)) + 11 | cos(_degreesToRadians(latitude1)) * 12 | cos(_degreesToRadians(latitude2)) * 13 | (sin(dLon / 2) * sin(dLon / 2)); 14 | 15 | final double c = 2 * atan2(sqrt(a), sqrt(1 - a)); 16 | 17 | return earthRadius * c; 18 | } 19 | 20 | double _degreesToRadians(double degrees) { 21 | return degrees * (pi / 180); 22 | } 23 | -------------------------------------------------------------------------------- /lib/core/utils/src/color_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class HexColor extends Color { 4 | static int _getColorFromHex(String hexColor) { 5 | hexColor = hexColor.toUpperCase().replaceAll("#", ""); 6 | if (hexColor.length == 6) { 7 | hexColor = "FF$hexColor"; 8 | } 9 | return int.parse(hexColor, radix: 16); 10 | } 11 | 12 | HexColor(final String hexColor) : super(_getColorFromHex(hexColor)); 13 | } 14 | -------------------------------------------------------------------------------- /lib/core/utils/src/date_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:intl/intl.dart'; 2 | 3 | class MonthUtil { 4 | static final List _months = [ 5 | "January", 6 | "February", 7 | "March", 8 | "April", 9 | "May", 10 | "June", 11 | "July", 12 | "August", 13 | "September", 14 | "October", 15 | "November", 16 | "December" 17 | ]; 18 | static String getMonthNameFromNumber(int monthNumber) { 19 | if (monthNumber < 1 || monthNumber > 12) { 20 | throw ArgumentError("Month number must be between 1 and 12."); 21 | } 22 | 23 | return _months[monthNumber - 1]; 24 | } 25 | 26 | static String getMonthNameFromDate(DateTime date) { 27 | return getMonthNameFromNumber(date.month); 28 | } 29 | } 30 | 31 | String durationToHHmm(DateTime duration) => 32 | DateFormat('HH:mm').format(duration); 33 | -------------------------------------------------------------------------------- /lib/core/utils/src/debounce.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | class Debounce { 6 | final int milliseconds; 7 | Timer? _timer; 8 | Debounce({this.milliseconds = 500}); 9 | 10 | void run(VoidCallback action) { 11 | if (_timer?.isActive ?? false) { 12 | _timer?.cancel(); 13 | } 14 | _timer = Timer(Duration(milliseconds: milliseconds), action); 15 | } 16 | 17 | void dispose() => _timer?.cancel(); 18 | } 19 | -------------------------------------------------------------------------------- /lib/core/utils/src/leg_utils.dart: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/core/utils/src/location_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | class LocationUtil { 4 | /// Calculates the distance between two geographical coordinates in kilometers 5 | /// using the Haversine formula. 6 | /// 7 | /// [lat1] - Latitude of the first point in degrees 8 | /// [lon1] - Longitude of the first point in degrees 9 | /// [lat2] - Latitude of the second point in degrees 10 | /// [lon2] - Longitude of the second point in degrees 11 | /// 12 | /// Returns the distance in kilometers 13 | static double getRadiusBetween( 14 | double lat1, 15 | double lon1, 16 | double lat2, 17 | double lon2, 18 | ) { 19 | const double earthRadius = 6371; // Earth's radius in kilometers 20 | 21 | // Convert degrees to radians 22 | final double lat1Rad = _degreesToRadians(lat1); 23 | final double lon1Rad = _degreesToRadians(lon1); 24 | final double lat2Rad = _degreesToRadians(lat2); 25 | final double lon2Rad = _degreesToRadians(lon2); 26 | 27 | // Differences in coordinates 28 | final double dLat = lat2Rad - lat1Rad; 29 | final double dLon = lon2Rad - lon1Rad; 30 | 31 | // Haversine formula 32 | final double a = sin(dLat / 2) * sin(dLat / 2) + 33 | cos(lat1Rad) * cos(lat2Rad) * sin(dLon / 2) * sin(dLon / 2); 34 | 35 | final double c = 2 * atan2(sqrt(a), sqrt(1 - a)); 36 | 37 | // Calculate distance 38 | return earthRadius * c; 39 | } 40 | 41 | /// Converts degrees to radians 42 | static double _degreesToRadians(double degrees) { 43 | return degrees * (pi / 180.0); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/core/utils/src/print_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:core'; 2 | 3 | import 'package:flutter/foundation.dart' as foundation; 4 | import 'package:flutter/foundation.dart' show debugPrint; 5 | import 'package:logger/logger.dart'; 6 | import 'package:universal_platform/universal_platform.dart'; 7 | 8 | class CustomOutput extends LogOutput { 9 | @override 10 | void output(OutputEvent event) { 11 | event.lines.forEach(debugPrint); 12 | } 13 | } 14 | 15 | var logger = Logger( 16 | printer: PrettyPrinter( 17 | methodCount: 2, 18 | errorMethodCount: 8, 19 | lineLength: 120, 20 | //colors: !UniversalPlatform.isIOS, 21 | printEmojis: true, 22 | printTime: true, 23 | ), 24 | output: CustomOutput(), 25 | ); 26 | 27 | /// Logging config 28 | void printLog([dynamic rawData, DateTime? startTime, Level? level]) { 29 | if (foundation.kDebugMode) { 30 | var time = ''; 31 | if (startTime != null) { 32 | final endTime = DateTime.now().difference(startTime); 33 | final icon = endTime.inMilliseconds > 2000 34 | ? '⌛️Slow-' 35 | : endTime.inMilliseconds > 1000 36 | ? '⏰Medium-' 37 | : '⚡️Fast-'; 38 | time = '[$icon${endTime.inMilliseconds}ms]'; 39 | } 40 | 41 | try { 42 | final data = '$rawData'; 43 | final log = '$time${data.toString()}'; 44 | 45 | /// print log for ios 46 | if (UniversalPlatform.isIOS) { 47 | debugPrint(log); 48 | return; 49 | } 50 | 51 | /// print log for android 52 | switch (level) { 53 | case Level.error: 54 | printError(log, StackTrace.empty); 55 | break; 56 | case Level.warning: 57 | logger.w(log, stackTrace: StackTrace.empty); 58 | break; 59 | case Level.info: 60 | logger.i(log, stackTrace: StackTrace.empty); 61 | break; 62 | case Level.debug: 63 | logger.d(log, stackTrace: StackTrace.empty); 64 | break; 65 | case Level.trace: 66 | logger.t(log, stackTrace: StackTrace.empty); 67 | break; 68 | default: 69 | if (time.startsWith('[⌛️Slow-')) { 70 | logger.f(log, stackTrace: StackTrace.empty); 71 | break; 72 | } 73 | if (time.startsWith('[⏰Medium-')) { 74 | logger.w(log, stackTrace: StackTrace.empty); 75 | break; 76 | } 77 | logger.t(log, stackTrace: StackTrace.empty); 78 | break; 79 | } 80 | } catch (err, trace) { 81 | printError(err, trace); 82 | } 83 | } 84 | } 85 | 86 | void printError(dynamic err, [dynamic trace, dynamic message]) { 87 | if (!foundation.kDebugMode) { 88 | return; 89 | } 90 | 91 | // final shouldHide = trace == null || 92 | // '$trace'.isEmpty || 93 | // '$trace'.contains('package:gofere_travelers'); 94 | //if (shouldHide) { 95 | // logger.d(err, error: message, stackTrace: StackTrace.empty); 96 | // return; 97 | // } 98 | 99 | logger.e(err, error: message ?? 'Stack trace:', stackTrace: trace); 100 | } 101 | -------------------------------------------------------------------------------- /lib/core/utils/src/safe_ui_api_call.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:weyalaw/core/utils/index.dart'; 3 | 4 | void safeUiApiCall(BuildContext context, 5 | {required Future Function() apiCall, 6 | Function(T)? onSuccess, 7 | Function(String)? onError}) async { 8 | try { 9 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { 10 | final result = await apiCall(); 11 | if (context.mounted) { 12 | onSuccess?.call(result); 13 | } 14 | }); 15 | } catch (e) { 16 | printError(e); 17 | onError?.call(e.toString()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/core/utils/src/simulate.dart: -------------------------------------------------------------------------------- 1 | class Simulate { 2 | static delay() async { 3 | await Future.delayed( 4 | const Duration(seconds: 3)); // Simulate a delay of 1 second 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /lib/core/utils/src/text_field_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class Validator { 4 | static String? validate(String? value, TextInputType inputType) { 5 | switch (inputType) { 6 | case TextInputType.emailAddress: 7 | return _validateEmail(value); 8 | case TextInputType.phone: 9 | return _validatePhone(value); 10 | case TextInputType.number: 11 | return _validateNumber(value); 12 | case TextInputType.url: 13 | return _validateUrl(value); 14 | case TextInputType.text: 15 | default: 16 | return _validateText(value); 17 | } 18 | } 19 | 20 | static String? _validateEmail(String? value) { 21 | if (value == null || value.isEmpty) { 22 | return 'Email is required'; 23 | } 24 | final RegExp emailExp = RegExp( 25 | r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9]+\.[a-zA-Z]+", 26 | ); 27 | if (!emailExp.hasMatch(value)) { 28 | return 'Enter a valid email'; 29 | } 30 | return null; 31 | } 32 | 33 | static String? _validatePhone(String? value) { 34 | if (value == null || value.isEmpty) { 35 | return 'Phone number is required'; 36 | } 37 | final RegExp phoneExp = RegExp(r'^\d{10}$'); 38 | if (!phoneExp.hasMatch(value)) { 39 | return 'Enter a valid phone number'; 40 | } 41 | return null; 42 | } 43 | 44 | static String? _validateNumber(String? value) { 45 | if (value == null || value.isEmpty) { 46 | return 'Number is required'; 47 | } 48 | final num? number = num.tryParse(value); 49 | if (number == null) { 50 | return 'Enter a valid number'; 51 | } 52 | return null; 53 | } 54 | 55 | static String? _validateUrl(String? value) { 56 | if (value == null || value.isEmpty) { 57 | return 'URL is required'; 58 | } 59 | final RegExp urlExp = RegExp( 60 | r"^(https?|ftp)://[^\s/$.?#].[^\s]*$", 61 | ); 62 | if (!urlExp.hasMatch(value)) { 63 | return 'Enter a valid URL'; 64 | } 65 | return null; 66 | } 67 | 68 | static String? _validateText(String? value) { 69 | if (value == null || value.isEmpty) { 70 | return 'This field is required'; 71 | } 72 | if (value.length < 3) { 73 | return 'Text must be at least 3 characters long'; 74 | } 75 | return null; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/firebase_options.dart: -------------------------------------------------------------------------------- 1 | // File generated by FlutterFire CLI. 2 | // ignore_for_file: type=lint 3 | import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; 4 | import 'package:flutter/foundation.dart' 5 | show defaultTargetPlatform, kIsWeb, TargetPlatform; 6 | 7 | /// Default [FirebaseOptions] for use with your Firebase apps. 8 | /// 9 | /// Example: 10 | /// ```dart 11 | /// import 'firebase_options.dart'; 12 | /// // ... 13 | /// await Firebase.initializeApp( 14 | /// options: DefaultFirebaseOptions.currentPlatform, 15 | /// ); 16 | /// ``` 17 | class DefaultFirebaseOptions { 18 | static FirebaseOptions get currentPlatform { 19 | if (kIsWeb) { 20 | throw UnsupportedError( 21 | 'DefaultFirebaseOptions have not been configured for web - ' 22 | 'you can reconfigure this by running the FlutterFire CLI again.', 23 | ); 24 | } 25 | switch (defaultTargetPlatform) { 26 | case TargetPlatform.android: 27 | return android; 28 | case TargetPlatform.iOS: 29 | return ios; 30 | case TargetPlatform.macOS: 31 | throw UnsupportedError( 32 | 'DefaultFirebaseOptions have not been configured for macos - ' 33 | 'you can reconfigure this by running the FlutterFire CLI again.', 34 | ); 35 | case TargetPlatform.windows: 36 | throw UnsupportedError( 37 | 'DefaultFirebaseOptions have not been configured for windows - ' 38 | 'you can reconfigure this by running the FlutterFire CLI again.', 39 | ); 40 | case TargetPlatform.linux: 41 | throw UnsupportedError( 42 | 'DefaultFirebaseOptions have not been configured for linux - ' 43 | 'you can reconfigure this by running the FlutterFire CLI again.', 44 | ); 45 | default: 46 | throw UnsupportedError( 47 | 'DefaultFirebaseOptions are not supported for this platform.', 48 | ); 49 | } 50 | } 51 | 52 | static const FirebaseOptions android = FirebaseOptions( 53 | apiKey: 'AIzaSyAbV1UzTazneUXlsjPGy9ggmTXFAAcMCYM', 54 | appId: '1:341778370735:android:4ba300a5525281ea87445a', 55 | messagingSenderId: '341778370735', 56 | projectId: 'bus-tracking-9d873', 57 | storageBucket: 'bus-tracking-9d873.firebasestorage.app', 58 | ); 59 | 60 | static const FirebaseOptions ios = FirebaseOptions( 61 | apiKey: 'AIzaSyA-6Yp6ehkzW_4CcFtc0rRXNhEJyMBX73g', 62 | appId: '1:341778370735:ios:7cf28b3ac66e49bb87445a', 63 | messagingSenderId: '341778370735', 64 | projectId: 'bus-tracking-9d873', 65 | storageBucket: 'bus-tracking-9d873.firebasestorage.app', 66 | iosBundleId: 'com.mrnpro.goFindTaxi', 67 | ); 68 | } 69 | -------------------------------------------------------------------------------- /lib/hooks/debounce.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_hooks/flutter_hooks.dart'; 4 | import 'package:rxdart/rxdart.dart'; 5 | 6 | TextEditingController useDebouncedTextController( 7 | void Function(String) onDebounce) { 8 | final textController = useTextEditingController(); 9 | 10 | useEffect(() { 11 | final behaviorSubject = BehaviorSubject(); 12 | StreamSubscription? streamSubscription; 13 | 14 | textController.addListener(() { 15 | behaviorSubject.add(textController.text); 16 | }); 17 | 18 | streamSubscription = behaviorSubject 19 | .where((event) => event.length >= 3) 20 | .debounceTime(const Duration(milliseconds: 500)) 21 | .distinct() 22 | .listen((event) { 23 | onDebounce(event); 24 | }); 25 | 26 | return () { 27 | streamSubscription?.cancel(); 28 | behaviorSubject.close(); 29 | }; 30 | }, [textController]); 31 | 32 | return textController; 33 | } 34 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_dotenv/flutter_dotenv.dart'; 4 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 5 | import 'package:weyalaw/core/services/index.dart'; 6 | 7 | import 'app.dart'; 8 | import 'core/analytics/observers/riverpod_loger.dart'; 9 | import 'core/services/OnlineService/httpService/http_service_impl.dart'; 10 | import 'core/services/localService/local_service_impl.dart'; 11 | import 'core/utils/index.dart'; 12 | 13 | late ProviderContainer container; 14 | void main() async { 15 | runZonedGuarded>(() async { 16 | WidgetsFlutterBinding.ensureInitialized(); 17 | await dotenv.load(fileName: ".env"); 18 | final httpImpl = HttpServiceImpl(); 19 | final localServiceImplementation = HiveLocalStorageService(); 20 | await localServiceImplementation.init(); 21 | container = ProviderContainer( 22 | observers: [RiverpodLogger()], 23 | overrides: [ 24 | httpServiceProvider.overrideWith( 25 | (ref) => httpImpl..init(), 26 | ), 27 | localStorageServiceProvider 28 | .overrideWith((ref) => localServiceImplementation), 29 | ], 30 | ); 31 | 32 | FlutterError.onError = (FlutterErrorDetails details) async { 33 | printLog( 34 | "--------------------------------- Sending to crash analytics ----------------------"); 35 | // await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); 36 | 37 | // await FirebaseCrashlytics.instance 38 | // .recordFlutterError(details, fatal: true); 39 | printLog("--------------------------- sent ---------------------------"); 40 | }; 41 | runApp(UncontrolledProviderScope(container: container, child: const App())); 42 | }, (error, stack) { 43 | printError(error); 44 | }); 45 | } 46 | -------------------------------------------------------------------------------- /lib/modules/transit/core/map_utils.dart: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/modules/transit/core/price_calculator.dart: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/modules/transit/core/search_focus_enum.dart: -------------------------------------------------------------------------------- 1 | enum SearchFocus { 2 | from, 3 | to, 4 | } 5 | -------------------------------------------------------------------------------- /lib/modules/transit/data/datasource/redat_data_source.dart: -------------------------------------------------------------------------------- 1 | import 'package:weyalaw/core/handlers/result.dart'; 2 | import 'package:weyalaw/core/services/OnlineService/httpService/http_service.dart'; 3 | import 'package:weyalaw/modules/transit/data/datasource/transit_data_source.dart'; 4 | import 'package:weyalaw/modules/transit/data/models/transport_place_model.dart'; 5 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 6 | 7 | import '../../../../core/config/api/api_endpoints.dart'; 8 | import '../../../../core/handlers/failure/failure.dart'; 9 | import '../../../../core/handlers/success/success.dart'; 10 | import '../models/redat-model/transport_option_redatmodel.dart'; 11 | 12 | final redatDataSourceProvider = Provider((ref) { 13 | final httpService = ref.read(httpServiceProvider); 14 | return RedatDataSource(httpService); 15 | }); 16 | 17 | class RedatDataSource implements TransitDataSource { 18 | final HttpService _httpService; 19 | 20 | RedatDataSource(this._httpService); 21 | 22 | @override 23 | FutureResult> getTransportRouteFromTwoPoints( 24 | {required TransportPlace from, required TransportPlace to}) async { 25 | try { 26 | final response = await _httpService.getRequest( 27 | urlPath: APIEndpoints.redatBaseUrl + APIEndpoints.redatRouteMap, 28 | queryParam: { 29 | 'from': from.name, 30 | 'to': to.name, 31 | }, 32 | header: { 33 | 'accept': '*/*', 34 | 'accept-language': 'en-US,en;q=0.9', 35 | 'origin': 'https://redat.vercel.app', 36 | 'referer': 'https://redat.vercel.app/', 37 | 'sec-fetch-dest': 'empty', 38 | 'sec-fetch-mode': 'cors', 39 | 'sec-fetch-site': 'cross-site', 40 | }, 41 | ); 42 | 43 | if (response.data == null) { 44 | return Failure.send(error: 'No data received from Redat API'); 45 | } 46 | 47 | final options = [TransportOptionRedatModel.fromJson(response.data)]; 48 | 49 | return Success.send(data: options); 50 | } catch (e) { 51 | return Failure.send(error: e); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/modules/transit/data/datasource/transit_data_source.dart: -------------------------------------------------------------------------------- 1 | import 'package:weyalaw/modules/transit/entities/transport_option_entity.dart'; 2 | 3 | import '../../../../core/handlers/result.dart'; 4 | import '../models/transport_place_model.dart'; 5 | 6 | abstract class TransitDataSource { 7 | FutureResult> getTransportRouteFromTwoPoints( 8 | {required TransportPlace from, required TransportPlace to}); 9 | } 10 | -------------------------------------------------------------------------------- /lib/modules/transit/data/datasource/weyalaw_data_source.dart: -------------------------------------------------------------------------------- 1 | import 'package:weyalaw/core/handlers/result.dart'; 2 | import 'package:weyalaw/core/services/OnlineService/httpService/http_service.dart'; 3 | import 'package:weyalaw/modules/transit/data/datasource/transit_data_source.dart'; 4 | import 'package:weyalaw/modules/transit/data/models/transport_place_model.dart'; 5 | import 'package:weyalaw/modules/transit/data/models/weyalaw-model/transport_option_weyalawmodel.dart'; 6 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 7 | 8 | import '../../../../core/config/api/api_endpoints.dart'; 9 | import '../../../../core/handlers/failure/failure.dart'; 10 | import '../../../../core/handlers/success/success.dart'; 11 | 12 | final weyalawDataSourceProvider = Provider((ref) { 13 | final httpService = ref.read(httpServiceProvider); 14 | return WeyalawDataSource(httpService); 15 | }); 16 | 17 | class WeyalawDataSource implements TransitDataSource { 18 | final HttpService _httpService; 19 | 20 | WeyalawDataSource(this._httpService); 21 | @override 22 | FutureResult> 23 | getTransportRouteFromTwoPoints( 24 | {required TransportPlace from, required TransportPlace to}) async { 25 | try { 26 | final response = await _httpService 27 | .getRequest(urlPath: APIEndpoints.transportOptions, queryParam: { 28 | 'from': '${from.coordinates?.latitude},${from.coordinates?.longitude}', 29 | 'to': '${to.coordinates?.latitude},${to.coordinates?.longitude}', 30 | }); 31 | final options = []; 32 | for (var option in response.data) { 33 | options.add(TransportOptionWeyalawModel.fromJson(option)); 34 | } 35 | return Success.send(data: options); 36 | } catch (e) { 37 | return Failure.send(error: e); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/redat-model/coordinates_redatmodel.dart: -------------------------------------------------------------------------------- 1 | import '../../../entities/coordinates_entity.dart'; 2 | 3 | class CoordinatesRedatModel extends CoordinatesEntity { 4 | const CoordinatesRedatModel({ 5 | required super.lat, 6 | required super.lng, 7 | }); 8 | 9 | factory CoordinatesRedatModel.fromJson(Map json) { 10 | final coordinates = json['coordinates'] as List; 11 | return CoordinatesRedatModel( 12 | lng: coordinates[0] as double, 13 | lat: coordinates[1] as double, 14 | ); 15 | } 16 | 17 | Map toJson() => { 18 | 'type': 'Point', 19 | 'coordinates': [lng, lat], 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/redat-model/place_redatmodel.dart: -------------------------------------------------------------------------------- 1 | import '../../../entities/place_entity.dart'; 2 | import 'coordinates_redatmodel.dart'; 3 | 4 | class PlaceRedatModel extends PlaceEntity { 5 | final String id; 6 | final List? connectedRoutes; 7 | 8 | const PlaceRedatModel({ 9 | required super.name, 10 | required super.coordinates, 11 | required this.id, 12 | this.connectedRoutes, 13 | }); 14 | 15 | factory PlaceRedatModel.fromJson(Map json) => PlaceRedatModel( 16 | id: json['id'] as String, 17 | name: json['name'] as String, 18 | coordinates: CoordinatesRedatModel.fromJson(json['location'] as Map), 19 | connectedRoutes: (json['connected_routes'] as List?)?.map((e) => e as String).toList(), 20 | ); 21 | 22 | Map toJson() => { 23 | 'id': id, 24 | 'name': name, 25 | 'location': (coordinates as CoordinatesRedatModel).toJson(), 26 | 'connected_routes': connectedRoutes, 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/redat-model/transport_option_redatmodel.dart: -------------------------------------------------------------------------------- 1 | import '../../../entities/transport_option_entity.dart'; 2 | import 'place_redatmodel.dart'; 3 | import 'transport_step_redatmodel.dart'; 4 | 5 | class TransportOptionRedatModel extends TransportOptionEntity { 6 | const TransportOptionRedatModel({ 7 | required super.option, 8 | required super.totalDuration, 9 | required super.totalPrice, 10 | required super.steps, 11 | }); 12 | 13 | factory TransportOptionRedatModel.fromJson(Map json) { 14 | final routeList = (json['route'] as List) 15 | .map((e) => PlaceRedatModel.fromJson(e as Map)) 16 | .toList(); 17 | 18 | final steps = (json['legs'] as List) 19 | .map((e) => TransportStepRedatModel.fromJson(e as Map)) 20 | .toList(); 21 | 22 | return TransportOptionRedatModel( 23 | option: 'transit', 24 | totalDuration: json['duration'] as int, 25 | totalPrice: (json['total_price'] as num).toDouble(), 26 | steps: steps, 27 | ); 28 | } 29 | 30 | Map toJson() => { 31 | 'total_price': totalPrice, 32 | 'duration': totalDuration, 33 | 'legs': 34 | steps.map((e) => (e as TransportStepRedatModel).toJson()).toList(), 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/redat-model/transport_step_redatmodel.dart: -------------------------------------------------------------------------------- 1 | import 'package:weyalaw/modules/transit/data/models/redat-model/coordinates_redatmodel.dart'; 2 | 3 | import '../../../entities/transport_step_entity.dart'; 4 | import 'place_redatmodel.dart'; 5 | 6 | class TransportStepRedatModel extends TransportStepEntity { 7 | const TransportStepRedatModel({ 8 | required super.fromPlace, 9 | required super.toPlace, 10 | required super.duration, 11 | required super.action, 12 | required super.isTransit, 13 | required super.price, 14 | }); 15 | 16 | factory TransportStepRedatModel.fromJson(Map json) { 17 | final from = json['route']['0']; 18 | final to = json['route']['1']; 19 | return TransportStepRedatModel( 20 | fromPlace: PlaceRedatModel( 21 | id: from['id'] as String, 22 | name: from['name'] as String, 23 | coordinates: CoordinatesRedatModel.fromJson(from['location']), 24 | ), 25 | toPlace: PlaceRedatModel( 26 | id: to['id'] as String, 27 | name: to['name'] as String, 28 | coordinates: CoordinatesRedatModel.fromJson(to['location']), 29 | ), 30 | duration: 0, // Redat API provides this at the route level 31 | action: 'transit', // Default action for Redat 32 | isTransit: true, // Always true for Redat 33 | price: (json['price'] as num).toDouble(), 34 | ); 35 | } 36 | 37 | Map toJson() => { 38 | 'from': fromPlace.name, 39 | 'to': toPlace.name, 40 | 'price': price, 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/route.dart: -------------------------------------------------------------------------------- 1 | import 'package:google_maps_widget/google_maps_widget.dart'; 2 | 3 | class Route { 4 | final String name; 5 | final double price; 6 | final List? coordinates; 7 | 8 | Route({ 9 | required this.name, 10 | required this.price, 11 | this.coordinates, 12 | }); 13 | 14 | factory Route.fromJson(Map json) { 15 | return Route( 16 | name: json['name'], 17 | price: json['price'], 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/route_model.dart: -------------------------------------------------------------------------------- 1 | export 'route.dart'; 2 | export 'transport_route.dart'; 3 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/transport_place_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:weyalaw/core/constants.dart'; 2 | import 'package:weyalaw/core/services/LocationService/location_service.dart'; 3 | import 'package:google_maps_widget/google_maps_widget.dart'; 4 | 5 | import '../../../../core/services/LocationService/models/geo_coding_response.dart'; 6 | 7 | class TransportPlace { 8 | final String? name; 9 | 10 | final LatLng? coordinates; 11 | 12 | TransportPlace({ 13 | this.name, 14 | this.coordinates, 15 | }); 16 | 17 | factory TransportPlace.fromJson(List? json) { 18 | if (json == null) return TransportPlace(); 19 | 20 | return TransportPlace( 21 | name: json[0] as String?, 22 | coordinates: json[3] != null 23 | ? LatLng(json[3][1].toDouble(), json[3][0].toDouble()) 24 | : null, 25 | ); 26 | } 27 | static Future fromCurrentLocation() async { 28 | final currentLocation = 29 | await LocationService.getInstance().getCurrentLocation(); 30 | return TransportPlace( 31 | name: currentLocationString, coordinates: currentLocation); 32 | } 33 | 34 | factory TransportPlace.fromMap(Map map) { 35 | return TransportPlace( 36 | name: map['name'] as String?, 37 | coordinates: map['coordinates'] != null 38 | ? LatLng(map['coordinates'][1].toDouble(), 39 | map['coordinates'][0].toDouble()) 40 | : null, 41 | ); 42 | } 43 | 44 | factory TransportPlace.fromGeoCoding(GeoCoding geoCoding) { 45 | return TransportPlace( 46 | name: geoCoding.name, 47 | coordinates: LatLng(geoCoding.latitude?.toDouble() ?? 0, 48 | geoCoding.longitude?.toDouble() ?? 0), 49 | ); 50 | } 51 | 52 | Map toJson() { 53 | return { 54 | 'name': name, // index 0 55 | 'coordinates': coordinates != null // index 3 56 | ? [coordinates!.longitude, coordinates!.latitude] 57 | : null, 58 | }; 59 | } 60 | 61 | @override 62 | String toString() { 63 | return '${coordinates?.latitude}, ${coordinates?.longitude}'; 64 | } 65 | 66 | /// Creates a copy of this TransportPlace but with the given fields replaced with the new values. 67 | TransportPlace copyWith({ 68 | String? name, 69 | LatLng? coordinates, 70 | }) { 71 | return TransportPlace( 72 | name: name ?? this.name, 73 | coordinates: coordinates ?? this.coordinates, 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/transport_route.dart: -------------------------------------------------------------------------------- 1 | import 'package:google_maps_widget/google_maps_widget.dart'; 2 | import 'route.dart'; // Import the new Route model 3 | 4 | class TransportRoute { 5 | final String initialPoint; 6 | final String destination; 7 | final double distance; // in km 8 | final bool availability; 9 | final List routes; // List of Route objects 10 | final double price; // Estimated price for the transport route 11 | final List coordinates; 12 | 13 | TransportRoute({ 14 | required this.initialPoint, 15 | required this.destination, 16 | required this.distance, 17 | required this.availability, 18 | required this.routes, 19 | required this.price, 20 | required this.coordinates, 21 | }); 22 | 23 | factory TransportRoute.fromJson(Map json) { 24 | return TransportRoute( 25 | initialPoint: json['initialPoint'], 26 | destination: json['destination'], 27 | distance: json['distance'], 28 | availability: json['availability'], 29 | routes: (json['routes'] as List) 30 | .map((route) => Route.fromJson(route)) 31 | .toList(), 32 | price: json['price'], 33 | coordinates: (json['coordinates'] as List).map((coord) { 34 | final parts = coord.split(','); 35 | return LatLng(double.parse(parts[0]), double.parse(parts[1])); 36 | }).toList(), 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/weyalaw-model/coordinates_weyalawmodel.dart: -------------------------------------------------------------------------------- 1 | import '../../../entities/coordinates_entity.dart'; 2 | 3 | class CoordinatesWeyalawModel extends CoordinatesEntity { 4 | const CoordinatesWeyalawModel({ 5 | required super.lat, 6 | required super.lng, 7 | }); 8 | 9 | factory CoordinatesWeyalawModel.fromJson(Map json) => 10 | CoordinatesWeyalawModel( 11 | lat: json['lat'] as double, 12 | lng: json['lng'] as double, // 13 | ); 14 | 15 | Map toJson() => { 16 | 'lat': lat, 17 | 'lng': lng, 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/weyalaw-model/place_weyalawmodel.dart: -------------------------------------------------------------------------------- 1 | import '../../../entities/place_entity.dart'; 2 | import 'coordinates_weyalawmodel.dart'; 3 | 4 | class PlaceWeyalawModel extends PlaceEntity { 5 | const PlaceWeyalawModel({ 6 | required super.name, 7 | required super.coordinates, 8 | }); 9 | 10 | factory PlaceWeyalawModel.fromJson(Map json) => 11 | PlaceWeyalawModel( 12 | name: json['name'] as String, 13 | coordinates: CoordinatesWeyalawModel.fromJson( 14 | json['coordinates'] as Map), 15 | ); 16 | 17 | Map toJson() => { 18 | 'placeName': name, 19 | 'location': (coordinates as CoordinatesWeyalawModel).toJson(), 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/weyalaw-model/transport_option_weyalawmodel.dart: -------------------------------------------------------------------------------- 1 | import '../../../entities/transport_option_entity.dart'; 2 | import 'transport_step_weyalawmodel.dart'; 3 | 4 | class TransportOptionWeyalawModel extends TransportOptionEntity { 5 | const TransportOptionWeyalawModel({ 6 | required super.option, 7 | required super.totalDuration, 8 | required super.totalPrice, 9 | required super.steps, 10 | }); 11 | 12 | factory TransportOptionWeyalawModel.fromJson(Map json) => 13 | TransportOptionWeyalawModel( 14 | option: json['option'] as String, 15 | totalDuration: json['totalDuration'] as int, 16 | totalPrice: (json['totalPrice'] as num).toDouble(), 17 | steps: (json['steps'] as List) 18 | .map((e) => 19 | TransportStepWeyalawModel.fromJson(e as Map)) 20 | .toList(), 21 | ); 22 | 23 | Map toJson() => { 24 | 'routeType': option, 25 | 'totalDuration': totalDuration, 26 | 'totalPrice': totalPrice, 27 | 'steps': steps 28 | .map((e) => (e as TransportStepWeyalawModel).toJson()) 29 | .toList(), 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /lib/modules/transit/data/models/weyalaw-model/transport_step_weyalawmodel.dart: -------------------------------------------------------------------------------- 1 | import '../../../entities/transport_step_entity.dart'; 2 | import 'place_weyalawmodel.dart'; 3 | 4 | class TransportStepWeyalawModel extends TransportStepEntity { 5 | const TransportStepWeyalawModel({ 6 | required super.fromPlace, 7 | required super.toPlace, 8 | required super.duration, 9 | required super.action, 10 | required super.isTransit, 11 | required super.price, 12 | }); 13 | 14 | factory TransportStepWeyalawModel.fromJson(Map json) => 15 | TransportStepWeyalawModel( 16 | fromPlace: PlaceWeyalawModel.fromJson( 17 | json['fromPlace'] as Map), 18 | toPlace: 19 | PlaceWeyalawModel.fromJson(json['toPlace'] as Map), 20 | duration: json['duration'] as int, 21 | action: json['action'] as String, 22 | isTransit: json['isTransit'] as bool, 23 | price: (json['price'] as num).toDouble(), 24 | ); 25 | 26 | Map toJson() => { 27 | 'source': (fromPlace as PlaceWeyalawModel).toJson(), 28 | 'destination': (toPlace as PlaceWeyalawModel).toJson(), 29 | 'travelTime': duration, 30 | 'travelMode': action, 31 | 'isPublicTransport': isTransit, 32 | 'fare': price, 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /lib/modules/transit/data/repositories/remote/i_route_remote.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_manual_providers_as_generated_provider_dependency 2 | /// This file defines the interface for the remote repository of the `route` module. 3 | /// 4 | /// The `IRouteRepoRemote` interface is intended to provide a contract for 5 | /// remote data operations related to the `route` module. Implementations 6 | /// of this interface should handle all remote data interactions, such as API calls, network 7 | /// requests, or any other form of remote data fetching. 8 | /// 9 | /// Usage: 10 | /// 11 | /// ```dart 12 | /// class RouteRepoRemoteImpl implements IRouteRepoRemote { 13 | /// // Implement the methods defined in the interface 14 | /// } 15 | /// 16 | /// final remoteRepository = RouteRepoRemoteImpl(); 17 | /// // Use remoteRepository to perform remote data operations 18 | /// ``` 19 | /// 20 | /// This approach ensures that the remote data operations are abstracted and can be easily 21 | /// swapped or mocked for testing purposes. 22 | library; 23 | 24 | import 'package:weyalaw/core/handlers/result.dart'; 25 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 26 | import 'package:riverpod_annotation/riverpod_annotation.dart'; 27 | import '../../../../../core/services/LocationService/location_service.dart'; 28 | import '../../../entities/transport_option_entity.dart'; 29 | import '../../datasource/redat_data_source.dart'; 30 | import '../../datasource/weyalaw_data_source.dart'; 31 | import '../../models/transport_place_model.dart'; 32 | import 'route_remote_impl.dart'; 33 | 34 | part 'i_route_remote.g.dart'; 35 | 36 | @Riverpod(keepAlive: true) 37 | IRouteRepoRemote routeRepoRemote(Ref ref) { 38 | final redatDataSource = ref.read(redatDataSourceProvider); 39 | final weyalawDataSource = ref.read(weyalawDataSourceProvider); 40 | final locationService = LocationService.getInstance(); 41 | return RouteRepoRemoteImpl( 42 | locationService, redatDataSource, weyalawDataSource); 43 | } 44 | 45 | abstract class IRouteRepoRemote { 46 | FutureResult> searchTransportPlaceByName( 47 | {required String name}); 48 | FutureResult> getTransportRouteFromTwoPoints( 49 | {required TransportPlace from, 50 | required TransportPlace to, 51 | bool skipCache = false}); 52 | 53 | FutureResult cacheLastedUsedDestination( 54 | {required TransportPlace destination}); 55 | FutureResult> getLastedUsedDestination(); 56 | FutureResult cacheLastUsedOrigin({required TransportPlace origin}); 57 | FutureResult> getLastUsedOrigins(); 58 | } 59 | -------------------------------------------------------------------------------- /lib/modules/transit/data/repositories/remote/i_route_remote.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'i_route_remote.dart'; 4 | 5 | // ************************************************************************** 6 | // RiverpodGenerator 7 | // ************************************************************************** 8 | 9 | String _$routeRepoRemoteHash() => r'2a1030bf0f453b4d02711cdbb3641755de18432d'; 10 | 11 | /// See also [routeRepoRemote]. 12 | @ProviderFor(routeRepoRemote) 13 | final routeRepoRemoteProvider = Provider.internal( 14 | routeRepoRemote, 15 | name: r'routeRepoRemoteProvider', 16 | debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') 17 | ? null 18 | : _$routeRepoRemoteHash, 19 | dependencies: null, 20 | allTransitiveDependencies: null, 21 | ); 22 | 23 | @Deprecated('Will be removed in 3.0. Use Ref instead') 24 | // ignore: unused_element 25 | typedef RouteRepoRemoteRef = ProviderRef; 26 | // ignore_for_file: type=lint 27 | // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package 28 | -------------------------------------------------------------------------------- /lib/modules/transit/entities/coordinates_entity.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:google_maps_widget/google_maps_widget.dart'; 3 | 4 | class CoordinatesEntity extends Equatable { 5 | final double lat; 6 | final double lng; 7 | 8 | const CoordinatesEntity({ 9 | required this.lat, 10 | required this.lng, 11 | }); 12 | 13 | LatLng toLatLng() => LatLng(lat, lng); 14 | 15 | @override 16 | List get props => [lat, lng]; 17 | } 18 | -------------------------------------------------------------------------------- /lib/modules/transit/entities/place_entity.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'coordinates_entity.dart'; 3 | 4 | class PlaceEntity extends Equatable { 5 | final String name; 6 | final CoordinatesEntity coordinates; 7 | 8 | const PlaceEntity({ 9 | required this.name, 10 | required this.coordinates, 11 | }); 12 | 13 | @override 14 | List get props => [name, coordinates]; 15 | } 16 | -------------------------------------------------------------------------------- /lib/modules/transit/entities/transport_option_entity.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'transport_step_entity.dart'; 3 | 4 | class TransportOptionEntity extends Equatable { 5 | final String option; 6 | final int totalDuration; 7 | final double totalPrice; 8 | final List steps; 9 | 10 | const TransportOptionEntity({ 11 | required this.option, 12 | required this.totalDuration, 13 | required this.totalPrice, 14 | required this.steps, 15 | }); 16 | 17 | @override 18 | List get props => [ 19 | option, 20 | totalDuration, 21 | totalPrice, 22 | steps, 23 | ]; 24 | } 25 | -------------------------------------------------------------------------------- /lib/modules/transit/entities/transport_step_entity.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'place_entity.dart'; 3 | 4 | class TransportStepEntity extends Equatable { 5 | final PlaceEntity fromPlace; 6 | final PlaceEntity toPlace; 7 | final int duration; 8 | final String action; 9 | final bool isTransit; 10 | final double price; 11 | 12 | const TransportStepEntity({ 13 | required this.fromPlace, 14 | required this.toPlace, 15 | required this.duration, 16 | required this.action, 17 | required this.isTransit, 18 | required this.price, 19 | }); 20 | 21 | @override 22 | List get props => [ 23 | fromPlace, 24 | toPlace, 25 | duration, 26 | action, 27 | isTransit, 28 | price, 29 | ]; 30 | } 31 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/dialogs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/lib/modules/transit/presentation/dialogs/.gitkeep -------------------------------------------------------------------------------- /lib/modules/transit/presentation/dialogs/no_route_found_alert.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void showNoRouteFoundAlert(BuildContext context) { 4 | showDialog( 5 | context: context, 6 | builder: (context) => AlertDialog( 7 | title: const Text("Oops!"), 8 | content: const Text( 9 | "Couldn't find any route similar to your search. Please try another route."), 10 | actions: [ 11 | TextButton( 12 | onPressed: () => Navigator.pop(context), 13 | child: const Text("OK"), 14 | ), 15 | ], 16 | ), 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/error_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class ErrorScreen extends StatelessWidget { 4 | final Exception? error; 5 | 6 | const ErrorScreen({super.key, this.error}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Scaffold( 11 | body: Center( 12 | child: Text('Error: ${error?.toString() ?? 'Unknown error'}'), 13 | ), 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/main_screen.dart: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/pages.dart: -------------------------------------------------------------------------------- 1 | export 'see_all_transport_route.dart'; 2 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/ride_details_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class RideDetailsScreen extends StatelessWidget { 4 | final String rideId; 5 | 6 | const RideDetailsScreen({super.key, required this.rideId}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Scaffold( 11 | body: Center( 12 | child: Text('Ride Details Screen - ID: $rideId'), 13 | ), 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/searchPage/components/back_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:weyalaw/_shared/presentation/widgets/back_btn.dart'; 3 | 4 | class BackButtonWidget extends StatelessWidget { 5 | const BackButtonWidget({super.key}); 6 | 7 | @override 8 | Widget build(BuildContext context) { 9 | return const Padding( 10 | padding: EdgeInsets.symmetric(horizontal: 24), 11 | child: Align( 12 | alignment: Alignment.centerLeft, 13 | child: BackBtn(), 14 | ), 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/searchPage/components/components.dart: -------------------------------------------------------------------------------- 1 | export 'back_button.dart'; 2 | export 'location_picker.dart'; 3 | export 'set_new_destination.dart'; 4 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/searchPage/components/set_new_destination.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:gap/gap.dart'; 3 | import 'package:weyalaw/_shared/presentation/widgets/app_container.dart'; 4 | 5 | class SetNewDestination extends StatelessWidget { 6 | const SetNewDestination({super.key}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Padding( 11 | padding: const EdgeInsets.symmetric(horizontal: 24), 12 | child: Row( 13 | children: [ 14 | Expanded( 15 | child: AppContainer( 16 | padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 22), 17 | child: Row( 18 | children: [ 19 | Icon( 20 | Icons.map_outlined, 21 | color: Colors.black.withOpacity(.30), 22 | ), 23 | const Gap(9), 24 | Text( 25 | "Set A New Destination", 26 | style: TextStyle( 27 | fontSize: 16, 28 | fontWeight: FontWeight.bold, 29 | color: Colors.black.withOpacity(.30), 30 | ), 31 | ), 32 | ], 33 | ), 34 | ), 35 | ), 36 | const Gap(15), 37 | AppContainer( 38 | padding: const EdgeInsets.all(20), 39 | child: Text( 40 | "Go", 41 | style: TextStyle( 42 | color: Colors.black.withOpacity(.30), 43 | fontSize: 16, 44 | fontWeight: FontWeight.bold, 45 | ), 46 | ), 47 | ) 48 | ], 49 | ), 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/search_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class SearchScreen extends StatelessWidget { 4 | const SearchScreen({super.key}); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return const Scaffold( 9 | body: Center( 10 | child: Text('Search Screen'), 11 | ), 12 | ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/see_all_transport_route.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 3 | 4 | class SeeAllTransportRoute extends StatefulHookConsumerWidget { 5 | const SeeAllTransportRoute({super.key}); 6 | 7 | @override 8 | ConsumerState createState() => 9 | _SeeAllTransportState(); 10 | } 11 | 12 | class _SeeAllTransportState extends ConsumerState { 13 | @override 14 | Widget build(BuildContext context) { 15 | return Container(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/share_location_wrapper.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:weyalaw/modules/transit/data/models/transport_place_model.dart'; 4 | import 'package:go_router/go_router.dart'; 5 | import 'package:google_maps_widget/google_maps_widget.dart'; 6 | 7 | import '../../../../core/config/router/route_name.dart'; 8 | 9 | class ShareLocationWrapper extends ConsumerStatefulWidget { 10 | final double latitude; 11 | final double longitude; 12 | 13 | const ShareLocationWrapper({ 14 | super.key, 15 | required this.latitude, 16 | required this.longitude, 17 | }); 18 | 19 | @override 20 | ConsumerState createState() => 21 | _ShareLocationWrapperState(); 22 | } 23 | 24 | class _ShareLocationWrapperState extends ConsumerState { 25 | @override 26 | void initState() { 27 | super.initState(); 28 | _initializeAndNavigate(); 29 | } 30 | 31 | Future _initializeAndNavigate() async { 32 | try { 33 | // Get current location as 'from' place 34 | final fromPlace = await TransportPlace.fromCurrentLocation(); 35 | 36 | // Create destination place from shared coordinates 37 | final toPlace = TransportPlace( 38 | name: 'Shared Location', 39 | coordinates: LatLng(widget.latitude, widget.longitude), 40 | ); 41 | 42 | // Navigate to transit overview 43 | if (mounted) { 44 | context.pushReplacement(RouteName.transitOverview, extra: { 45 | 'from': fromPlace, 46 | 'to': toPlace, 47 | // 'plan': const Plan(), // You might want to fetch the actual plan here 48 | }); 49 | } 50 | } catch (e) { 51 | if (mounted) { 52 | ScaffoldMessenger.of(context).showSnackBar( 53 | SnackBar(content: Text('Error: ${e.toString()}')), 54 | ); 55 | } 56 | } 57 | } 58 | 59 | @override 60 | Widget build(BuildContext context) { 61 | return const Scaffold( 62 | body: Center( 63 | child: CircularProgressIndicator(), 64 | ), 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/transitOverview/components/components.dart: -------------------------------------------------------------------------------- 1 | export 'selected_route_detailed_information.dart'; 2 | export '../../../widgets/background_map.dart'; 3 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/pages/transitOverview/transit_overview_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:weyalaw/_shared/presentation/widgets/back_btn.dart'; 3 | import 'package:weyalaw/core/constants.dart'; 4 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 5 | 6 | import '../../../data/models/transport_place_model.dart'; 7 | import '../../../entities/transport_option_entity.dart'; 8 | import '../../widgets/route_display_widget.dart'; 9 | import 'components/components.dart'; 10 | 11 | class TransitOverviewPage extends StatefulHookConsumerWidget { 12 | const TransitOverviewPage( 13 | {super.key, required this.options, required this.from, required this.to}); 14 | 15 | final List options; 16 | final TransportPlace from; 17 | final TransportPlace to; 18 | @override 19 | ConsumerState createState() => 20 | _TransitOverviewPageState(); 21 | } 22 | 23 | class _TransitOverviewPageState extends ConsumerState { 24 | @override 25 | Widget build(BuildContext context) { 26 | return Scaffold( 27 | body: Stack( 28 | children: [ 29 | _buildMap(), 30 | _buildSelectedRouteDisplay(context), 31 | _buildRouteInformation() 32 | ], 33 | ), 34 | ); 35 | } 36 | 37 | Positioned _buildRouteInformation() { 38 | return Positioned( 39 | bottom: 0, 40 | left: 0, 41 | right: 0, 42 | child: SelectedRouteInformation( 43 | option: widget.options.first, from: widget.from, to: widget.to), 44 | ); 45 | } 46 | 47 | SafeArea _buildSelectedRouteDisplay(BuildContext context) { 48 | return SafeArea( 49 | child: Padding( 50 | padding: const EdgeInsets.symmetric(horizontal: kDefaultPadding), 51 | child: Column( 52 | children: [ 53 | const Align( 54 | alignment: Alignment.centerLeft, 55 | child: BackBtn(), 56 | ), 57 | RouteDisplayWidget( 58 | onTap: () {}, 59 | from: widget.from.name ?? "-", 60 | to: widget.to.name ?? "-", 61 | ), 62 | const Spacer(), 63 | ], 64 | ), 65 | ), 66 | ); 67 | } 68 | 69 | _buildMap() { 70 | return const BackgroundMap(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/lib/modules/transit/presentation/providers/.gitkeep -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/current-location-name/get_current_location_name.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:weyalaw/core/services/LocationService/location_service.dart'; 4 | import 'package:weyalaw/core/services/LocationService/models/reverse_geocoding_response.dart'; 5 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 6 | import 'package:riverpod_annotation/riverpod_annotation.dart'; 7 | part 'get_current_location_name.g.dart'; 8 | 9 | @riverpod 10 | Future currentLocationName(Ref ref) async { 11 | final locationService = LocationService.getInstance(); 12 | final currentLocation = await locationService.getCurrentLocation(); 13 | final locationNameResult = 14 | await locationService.reverseGeoCoding(currentLocation); 15 | return locationNameResult.first; 16 | } 17 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/current-location-name/get_current_location_name.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'get_current_location_name.dart'; 4 | 5 | // ************************************************************************** 6 | // RiverpodGenerator 7 | // ************************************************************************** 8 | 9 | String _$currentLocationNameHash() => 10 | r'ab66200b542a4358b59afcf1362b63147a0585a5'; 11 | 12 | /// See also [currentLocationName]. 13 | @ProviderFor(currentLocationName) 14 | final currentLocationNameProvider = 15 | AutoDisposeFutureProvider.internal( 16 | currentLocationName, 17 | name: r'currentLocationNameProvider', 18 | debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') 19 | ? null 20 | : _$currentLocationNameHash, 21 | dependencies: null, 22 | allTransitiveDependencies: null, 23 | ); 24 | 25 | @Deprecated('Will be removed in 3.0. Use Ref instead') 26 | // ignore: unused_element 27 | typedef CurrentLocationNameRef = AutoDisposeFutureProviderRef; 28 | // ignore_for_file: type=lint 29 | // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package 30 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/get-recent-transits/recent_transits_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 2 | import 'package:riverpod_annotation/riverpod_annotation.dart'; 3 | 4 | import '../../../data/models/transport_place_model.dart'; 5 | import '../../../data/repositories/remote/i_route_remote.dart'; 6 | part 'recent_transits_provider.g.dart'; 7 | 8 | @riverpod 9 | Future> 10 | getRecentTransits(Ref ref) async { 11 | final lastUsedOriginResult = 12 | await ref.read(routeRepoRemoteProvider).getLastUsedOrigins(); 13 | final lastUsedDestinationResult = 14 | await ref.read(routeRepoRemoteProvider).getLastedUsedDestination(); 15 | 16 | if (lastUsedOriginResult.failure != null) { 17 | return []; 18 | } 19 | final lastUsedOrigin = lastUsedOriginResult.success?.data; 20 | if (lastUsedDestinationResult.failure != null) { 21 | return []; 22 | } 23 | final lastUsedDestination = lastUsedDestinationResult.success?.data; 24 | if (lastUsedOrigin == null || lastUsedDestination == null) { 25 | return []; 26 | } 27 | final res = List.generate( 28 | lastUsedOrigin.length, 29 | (index) => (lastUsedOrigin[index], lastUsedDestination[index]), 30 | ); 31 | 32 | res.take(5); 33 | return res; 34 | } 35 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/get-recent-transits/recent_transits_provider.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'recent_transits_provider.dart'; 4 | 5 | // ************************************************************************** 6 | // RiverpodGenerator 7 | // ************************************************************************** 8 | 9 | String _$getRecentTransitsHash() => r'8ecd8320c7d9c24edb4cae361d6afc9616c793e6'; 10 | 11 | /// See also [getRecentTransits]. 12 | @ProviderFor(getRecentTransits) 13 | final getRecentTransitsProvider = AutoDisposeFutureProvider< 14 | List<(TransportPlace origin, TransportPlace destination)>>.internal( 15 | getRecentTransits, 16 | name: r'getRecentTransitsProvider', 17 | debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') 18 | ? null 19 | : _$getRecentTransitsHash, 20 | dependencies: null, 21 | allTransitiveDependencies: null, 22 | ); 23 | 24 | @Deprecated('Will be removed in 3.0. Use Ref instead') 25 | // ignore: unused_element 26 | typedef GetRecentTransitsRef = AutoDisposeFutureProviderRef< 27 | List<(TransportPlace origin, TransportPlace destination)>>; 28 | // ignore_for_file: type=lint 29 | // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package 30 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/getTransportRouteFromTwoPlace/get_transport_route_from_two_place_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:weyalaw/core/handlers/result.dart'; 2 | import 'package:weyalaw/modules/transit/data/models/transport_place_model.dart'; 3 | import 'package:riverpod_annotation/riverpod_annotation.dart'; 4 | import '../../../data/repositories/remote/i_route_remote.dart'; 5 | import 'state/get_transport_route_from_two_place_state.dart'; 6 | part 'get_transport_route_from_two_place_notifier.g.dart'; 7 | 8 | @riverpod 9 | class GetTransportRouteFromTwoPlaceNotifier 10 | extends _$GetTransportRouteFromTwoPlaceNotifier { 11 | @override 12 | GetTransportRouteFromTwoPlaceState build() { 13 | // this is your build . you can return any state you want 14 | return const GetTransportRouteFromTwoPlaceState.initial(); 15 | } 16 | 17 | Future getTransportRouteFromTwoPoints( 18 | {required TransportPlace from, required TransportPlace to}) async { 19 | final result = await ref 20 | .read(routeRepoRemoteProvider) 21 | .getTransportRouteFromTwoPoints(from: from, to: to); 22 | state = result.fold( 23 | onFailure: (l) => 24 | GetTransportRouteFromTwoPlaceState.failure(error: l.message ?? ""), 25 | onSuccess: (r) => 26 | GetTransportRouteFromTwoPlaceState.success(data: r.data), 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/getTransportRouteFromTwoPlace/get_transport_route_from_two_place_notifier.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'get_transport_route_from_two_place_notifier.dart'; 4 | 5 | // ************************************************************************** 6 | // RiverpodGenerator 7 | // ************************************************************************** 8 | 9 | String _$getTransportRouteFromTwoPlaceNotifierHash() => 10 | r'bfaa439529cef2e812bf9a3ed7ca9767fba4dd5a'; 11 | 12 | /// See also [GetTransportRouteFromTwoPlaceNotifier]. 13 | @ProviderFor(GetTransportRouteFromTwoPlaceNotifier) 14 | final getTransportRouteFromTwoPlaceNotifierProvider = 15 | AutoDisposeNotifierProvider.internal( 17 | GetTransportRouteFromTwoPlaceNotifier.new, 18 | name: r'getTransportRouteFromTwoPlaceNotifierProvider', 19 | debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') 20 | ? null 21 | : _$getTransportRouteFromTwoPlaceNotifierHash, 22 | dependencies: null, 23 | allTransitiveDependencies: null, 24 | ); 25 | 26 | typedef _$GetTransportRouteFromTwoPlaceNotifier 27 | = AutoDisposeNotifier; 28 | // ignore_for_file: type=lint 29 | // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package 30 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/getTransportRouteFromTwoPlace/state/get_transport_route_from_two_place_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:freezed_annotation/freezed_annotation.dart'; 2 | import '../../../../entities/transport_option_entity.dart'; 3 | 4 | part 'get_transport_route_from_two_place_state.freezed.dart'; 5 | 6 | @freezed 7 | class GetTransportRouteFromTwoPlaceState 8 | with _$GetTransportRouteFromTwoPlaceState { 9 | const factory GetTransportRouteFromTwoPlaceState.initial() = _Initial; 10 | const factory GetTransportRouteFromTwoPlaceState.loading() = _Loading; 11 | const factory GetTransportRouteFromTwoPlaceState.success( 12 | {required List data}) = _Success; 13 | const factory GetTransportRouteFromTwoPlaceState.failure( 14 | {required String error}) = _Failure; 15 | } 16 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/searchRoute/search_route_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:weyalaw/core/handlers/result.dart'; 2 | import 'package:weyalaw/modules/transit/data/repositories/remote/i_route_remote.dart'; 3 | import 'package:riverpod_annotation/riverpod_annotation.dart'; 4 | import 'state/search_route_state.dart'; 5 | part 'search_route_notifier.g.dart'; 6 | 7 | @riverpod 8 | class SearchRouteNotifier extends _$SearchRouteNotifier { 9 | @override 10 | SearchRouteState build() { 11 | // this is your build . you can return any state you want 12 | return const SearchRouteState.initial(); 13 | } 14 | 15 | Future search(String keyword) async { 16 | final repo = ref.read(routeRepoRemoteProvider); 17 | state = const SearchRouteState.loading(); 18 | final res = await repo.searchTransportPlaceByName(name: keyword); 19 | state = res.fold( 20 | onFailure: (e) => SearchRouteState.failure(error: e.toString()), 21 | onSuccess: (data) => SearchRouteState.success(data: data.data), 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/searchRoute/search_route_notifier.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'search_route_notifier.dart'; 4 | 5 | // ************************************************************************** 6 | // RiverpodGenerator 7 | // ************************************************************************** 8 | 9 | String _$searchRouteNotifierHash() => 10 | r'd57df3bba21c838e1d1723b4f91130c4905b4ed2'; 11 | 12 | /// See also [SearchRouteNotifier]. 13 | @ProviderFor(SearchRouteNotifier) 14 | final searchRouteNotifierProvider = 15 | AutoDisposeNotifierProvider.internal( 16 | SearchRouteNotifier.new, 17 | name: r'searchRouteNotifierProvider', 18 | debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') 19 | ? null 20 | : _$searchRouteNotifierHash, 21 | dependencies: null, 22 | allTransitiveDependencies: null, 23 | ); 24 | 25 | typedef _$SearchRouteNotifier = AutoDisposeNotifier; 26 | // ignore_for_file: type=lint 27 | // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package 28 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/searchRoute/state/search_route_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:freezed_annotation/freezed_annotation.dart'; 2 | 3 | import '../../../../data/models/transport_place_model.dart'; 4 | 5 | part 'search_route_state.freezed.dart'; 6 | 7 | @freezed 8 | class SearchRouteState with _$SearchRouteState { 9 | const factory SearchRouteState.initial() = _Initial; 10 | const factory SearchRouteState.loading() = _Loading; 11 | const factory SearchRouteState.success({required List data}) = 12 | _Success; 13 | const factory SearchRouteState.failure({required String error}) = _Failure; 14 | } 15 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/transportRoute/state/transport_route_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:freezed_annotation/freezed_annotation.dart'; 2 | 3 | import '../../../../data/models/route_model.dart'; 4 | 5 | part 'transport_route_state.freezed.dart'; 6 | 7 | @freezed 8 | class TransportRouteState with _$TransportRouteState { 9 | const factory TransportRouteState.initial() = _Initial; 10 | const factory TransportRouteState.loading() = _Loading; 11 | const factory TransportRouteState.gettingCurrentLocation() = 12 | _GettingCurrentLocation; 13 | const factory TransportRouteState.success(List data) = 14 | _Success; 15 | const factory TransportRouteState.failure({required String error}) = _Failure; 16 | } 17 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/transportRoute/transport_route_notifier.dart: -------------------------------------------------------------------------------- 1 | // import 'package:weyalaw/core/handlers/result.dart'; 2 | // import 'package:google_maps_widget/google_maps_widget.dart'; 3 | // import 'package:riverpod_annotation/riverpod_annotation.dart'; 4 | // import '../../../../../core/services/LocationService/location_service.dart'; 5 | // import '../../../data/models/route_model.dart'; 6 | // import '../../../data/repositories/remote/i_route_remote.dart'; 7 | // import 'state/transport_route_state.dart'; 8 | // part 'transport_route_notifier.g.dart'; 9 | 10 | // @riverpod 11 | // class TransportRouteNotifier extends _$TransportRouteNotifier { 12 | // @override 13 | // TransportRouteState build() { 14 | // // this is your build . you can return any state you want 15 | // return const TransportRouteState.initial(); 16 | // } 17 | 18 | // Future getTransportRoutes() async { 19 | // state = const TransportRouteState.gettingCurrentLocation(); 20 | // LatLng currentLocation; 21 | // try { 22 | // final locationService = LocationService.getInstance(); 23 | // currentLocation = await locationService.getCurrentLocation(); 24 | // } catch (e) { 25 | // state = TransportRouteState.failure(error: e.toString()); 26 | // return; 27 | // } 28 | // state = const TransportRouteState.loading(); 29 | // final result = await ref 30 | // .read(routeRepoRemoteProvider) 31 | // .getTransportRoutes(currentLocation: currentLocation); 32 | // result.fold(onSuccess: (data) { 33 | // state = TransportRouteState.success(data.data); 34 | // }, onFailure: (error) { 35 | // state = TransportRouteState.failure(error: error.message ?? ""); 36 | // }); 37 | // } 38 | // } 39 | 40 | import 'package:weyalaw/modules/transit/data/models/transport_place_model.dart'; 41 | import 'package:weyalaw/modules/transit/data/repositories/remote/i_route_remote.dart'; 42 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 43 | import 'package:riverpod_annotation/riverpod_annotation.dart'; 44 | 45 | import '../../../../../core/services/LocationService/location_service.dart'; 46 | import '../../../../../core/utils/src/location_util.dart'; 47 | 48 | part 'transport_route_notifier.g.dart'; 49 | 50 | @riverpod 51 | Future> fetchLastRoutes(Ref ref) async { 52 | final lastUsedDestinationResult = 53 | await ref.read(routeRepoRemoteProvider).getLastedUsedDestination(); 54 | if (lastUsedDestinationResult.failure != null) { 55 | return []; 56 | } 57 | 58 | final lastUsedDestination = lastUsedDestinationResult.success?.data; 59 | lastUsedDestination?.take(5); 60 | // filter out the the places that are the same as the current location 61 | /// filter: by cordinate radius . 62 | final currentLocation = 63 | await LocationService.getInstance().getCurrentLocation(); 64 | lastUsedDestination?.removeWhere((destination) { 65 | final distance = LocationUtil.getRadiusBetween( 66 | currentLocation.latitude, 67 | currentLocation.longitude, 68 | destination.coordinates!.latitude, 69 | destination.coordinates!.longitude, 70 | ); 71 | return distance < 5; 72 | }); 73 | return lastUsedDestination ?? []; 74 | } 75 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/providers/transportRoute/transport_route_notifier.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'transport_route_notifier.dart'; 4 | 5 | // ************************************************************************** 6 | // RiverpodGenerator 7 | // ************************************************************************** 8 | 9 | String _$fetchLastRoutesHash() => r'b34a63ca86d3f83f511199e2de1349e99c04cc7f'; 10 | 11 | /// See also [fetchLastRoutes]. 12 | @ProviderFor(fetchLastRoutes) 13 | final fetchLastRoutesProvider = 14 | AutoDisposeFutureProvider>.internal( 15 | fetchLastRoutes, 16 | name: r'fetchLastRoutesProvider', 17 | debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') 18 | ? null 19 | : _$fetchLastRoutesHash, 20 | dependencies: null, 21 | allTransitiveDependencies: null, 22 | ); 23 | 24 | @Deprecated('Will be removed in 3.0. Use Ref instead') 25 | // ignore: unused_element 26 | typedef FetchLastRoutesRef = AutoDisposeFutureProviderRef>; 27 | // ignore_for_file: type=lint 28 | // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package 29 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/widgets/background_map.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:google_maps_flutter/google_maps_flutter.dart'; 3 | import 'package:geolocator/geolocator.dart'; 4 | 5 | class BackgroundMap extends StatefulWidget { 6 | const BackgroundMap({super.key}); 7 | 8 | @override 9 | State createState() => _BackgroundMapState(); 10 | } 11 | 12 | class _BackgroundMapState extends State { 13 | late GoogleMapController mapController; 14 | Position? currentPosition; 15 | 16 | @override 17 | void initState() { 18 | super.initState(); 19 | _getCurrentLocation(); 20 | } 21 | 22 | Future _getCurrentLocation() async { 23 | bool serviceEnabled = await Geolocator.isLocationServiceEnabled(); 24 | if (!serviceEnabled) { 25 | return; 26 | } 27 | 28 | LocationPermission permission = await Geolocator.checkPermission(); 29 | if (permission == LocationPermission.denied) { 30 | permission = await Geolocator.requestPermission(); 31 | if (permission == LocationPermission.denied) { 32 | return; 33 | } 34 | } 35 | 36 | Position position = await Geolocator.getCurrentPosition(); 37 | setState(() { 38 | currentPosition = position; 39 | }); 40 | 41 | mapController.animateCamera( 42 | CameraUpdate.newCameraPosition( 43 | CameraPosition( 44 | target: LatLng(position.latitude, position.longitude), 45 | zoom: 15, 46 | ), 47 | ), 48 | ); 49 | } 50 | 51 | @override 52 | Widget build(BuildContext context) { 53 | return GoogleMap( 54 | initialCameraPosition: CameraPosition( 55 | target: LatLng( 56 | currentPosition?.latitude ?? 9.0320, 57 | currentPosition?.longitude ?? 58 | 38.7520), // Use current location or default to Addis Ababa 59 | zoom: 15, 60 | ), 61 | myLocationEnabled: true, 62 | myLocationButtonEnabled: true, 63 | onMapCreated: (GoogleMapController controller) { 64 | mapController = controller; 65 | }, 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/widgets/route_display_widget.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_hooks/flutter_hooks.dart'; 5 | import 'package:flutter_svg/svg.dart'; 6 | import 'package:gap/gap.dart'; 7 | import 'package:weyalaw/core/config/theme/color_pallete.dart'; 8 | import 'package:weyalaw/core/constants/assets.dart'; 9 | import 'package:weyalaw/core/extentions/app_shimmer.dart'; 10 | import 'package:hooks_riverpod/hooks_riverpod.dart'; 11 | 12 | import '../../../../_shared/presentation/widgets/app_container.dart'; 13 | 14 | class RouteDisplayWidget extends HookConsumerWidget { 15 | const RouteDisplayWidget({ 16 | super.key, 17 | required this.onTap, 18 | required this.from, 19 | required this.to, 20 | }); 21 | final FutureOr Function() onTap; 22 | final String from; 23 | final String to; 24 | @override 25 | Widget build(BuildContext context, ref) { 26 | final isLoading = useState(false); 27 | useEffect(() { 28 | // if is loading for a while , turn it off 29 | final timer = Timer(const Duration(seconds: 10), () { 30 | isLoading.value = false; 31 | }); 32 | return () { 33 | timer.cancel(); 34 | }; 35 | }, []); 36 | final widget = 37 | isLoading.value ? _loadingWhenPressed(isLoading) : _widget(isLoading); 38 | return Column( 39 | children: [ 40 | widget, 41 | const Gap(10), 42 | ], 43 | ); 44 | } 45 | 46 | Widget _loadingWhenPressed(ValueNotifier isLoading) { 47 | return Stack( 48 | children: [ 49 | _widget(isLoading), 50 | Positioned.fill( 51 | child: Container( 52 | decoration: BoxDecoration( 53 | borderRadius: BorderRadius.circular(12), 54 | border: Border.all(color: ColorPalette.primary, width: 3), 55 | ), 56 | ).appShimmer(), 57 | ), 58 | ], 59 | ); 60 | } 61 | 62 | Column _widget(ValueNotifier isLoading) { 63 | return Column( 64 | children: [ 65 | GestureDetector( 66 | onTap: () async { 67 | isLoading.value = true; 68 | await onTap(); 69 | isLoading.value = false; 70 | }, 71 | child: AppContainer( 72 | padding: const EdgeInsets.all(20), 73 | child: Row( 74 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 75 | children: [ 76 | Expanded( 77 | child: Text( 78 | from, 79 | maxLines: 2, 80 | )), 81 | const Gap(5), 82 | if (isLoading.value) 83 | SvgPicture.asset(Assets.assetsSvgsRouteProgress).appShimmer(), 84 | if (!isLoading.value) 85 | SvgPicture.asset(Assets.assetsSvgsRouteProgress), 86 | const Gap(5), 87 | Expanded( 88 | child: Align( 89 | alignment: Alignment.centerRight, 90 | child: Text( 91 | to, 92 | maxLines: 2, 93 | ), 94 | ), 95 | ), 96 | ], 97 | ), 98 | ), 99 | ), 100 | ], 101 | ); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /lib/modules/transit/presentation/widgets/widgets.dart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/lib/modules/transit/presentation/widgets/widgets.dart -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | void fl_register_plugins(FlPluginRegistry* registry) { 14 | g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar = 15 | fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin"); 16 | audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar); 17 | g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = 18 | fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); 19 | file_selector_plugin_register_with_registrar(file_selector_linux_registrar); 20 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 21 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 22 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 23 | } 24 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | audioplayers_linux 7 | file_selector_linux 8 | url_launcher_linux 9 | ) 10 | 11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 12 | ) 13 | 14 | set(PLUGIN_BUNDLED_LIBRARIES) 15 | 16 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 21 | endforeach(plugin) 22 | 23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 26 | endforeach(ffi_plugin) 27 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /mason-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "bricks": { 3 | "init_project": { 4 | "path": "/Users/mrn/Development/Projects/FlutterProjects/bricks/project_init/" 5 | }, 6 | "model": { 7 | "path": "/Users/mrn/Development/Projects/FlutterProjects/bricks/model/" 8 | }, 9 | "module": { 10 | "path": "/Users/mrn/Development/Projects/FlutterProjects/bricks/module/" 11 | }, 12 | "page": { 13 | "path": "/Users/mrn/Development/Projects/FlutterProjects/bricks/page/" 14 | }, 15 | "provider": { 16 | "path": "/Users/mrn/Development/Projects/FlutterProjects/bricks/provider/" 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /mason.yaml: -------------------------------------------------------------------------------- 1 | bricks: 2 | init_project: 3 | path: ../bricks/project_init 4 | model: 5 | path: ../bricks/model 6 | module: 7 | path: ../bricks/module 8 | page: 9 | path: ../bricks/page 10 | provider: 11 | path: ../bricks/provider -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | weyalaw 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weyalaw", 3 | "short_name": "weyalaw", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | void RegisterPlugins(flutter::PluginRegistry* registry) { 19 | AudioplayersWindowsPluginRegisterWithRegistrar( 20 | registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); 21 | ConnectivityPlusWindowsPluginRegisterWithRegistrar( 22 | registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); 23 | FileSelectorWindowsRegisterWithRegistrar( 24 | registry->GetRegistrarForPlugin("FileSelectorWindows")); 25 | FirebaseAuthPluginCApiRegisterWithRegistrar( 26 | registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); 27 | FirebaseCorePluginCApiRegisterWithRegistrar( 28 | registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); 29 | GeolocatorWindowsRegisterWithRegistrar( 30 | registry->GetRegistrarForPlugin("GeolocatorWindows")); 31 | LocalAuthPluginRegisterWithRegistrar( 32 | registry->GetRegistrarForPlugin("LocalAuthPlugin")); 33 | UrlLauncherWindowsRegisterWithRegistrar( 34 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 35 | } 36 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | audioplayers_windows 7 | connectivity_plus 8 | file_selector_windows 9 | firebase_auth 10 | firebase_core 11 | geolocator_windows 12 | local_auth_windows 13 | url_launcher_windows 14 | ) 15 | 16 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 17 | ) 18 | 19 | set(PLUGIN_BUNDLED_LIBRARIES) 20 | 21 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 23 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 26 | endforeach(plugin) 27 | 28 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 29 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 30 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 31 | endforeach(ffi_plugin) 32 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.mrnpro" "\0" 93 | VALUE "FileDescription", "weyalaw" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "weyalaw" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2024 com.mrnpro. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "weyalaw.exe" "\0" 98 | VALUE "ProductName", "weyalaw" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"weyalaw", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrnpro/Weyalaw/2b403db7857573b5bdff8c4a91033ca3ff9d3a23/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | unsigned int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length == 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | --------------------------------------------------------------------------------