├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ ├── google-services.json │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── mvvm_template │ │ │ │ └── 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 ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings ├── 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 │ ├── GoogleService-Info.plist │ ├── Info.plist │ └── Runner-Bridging-Header.h └── firebase_app_id_file.json ├── lib ├── app.dart ├── core │ ├── Routes │ │ ├── route_generator.dart │ │ └── routes.dart │ ├── config │ │ └── config.dart │ ├── constants │ │ ├── api_end_points.dart │ │ ├── constants.dart │ │ ├── my_utils.dart │ │ ├── strings.dart │ │ └── styles.dart │ ├── enums │ │ ├── env.dart │ │ └── view_state.dart │ ├── extensions │ │ └── double_extensions.dart │ ├── models │ │ ├── body │ │ │ ├── login_body.dart │ │ │ ├── reset_password_body.dart │ │ │ ├── signup_body.dart │ │ │ └── update_pasword_body.dart │ │ ├── other │ │ │ └── onboarding.dart │ │ ├── responses │ │ │ ├── auth_response.dart │ │ │ ├── base_responses │ │ │ │ ├── base_response.dart │ │ │ │ └── request_response.dart │ │ │ ├── onboarding_response.dart │ │ │ └── user_profile_response.dart │ │ └── user │ │ │ └── profile.dart │ ├── others │ │ ├── base_view_model.dart │ │ └── logger_customization │ │ │ ├── custom_log_output.dart │ │ │ ├── custom_log_printer.dart │ │ │ └── custom_logger.dart │ ├── services │ │ ├── api_services.dart │ │ ├── authentication │ │ │ ├── custom backend │ │ │ │ └── auth_service.dart │ │ │ └── firebase │ │ │ │ └── fire_auth.dart │ │ ├── database │ │ │ ├── custom backend │ │ │ │ └── database_service.dart │ │ │ └── firestore │ │ │ │ └── firebase_db_service.dart │ │ ├── date_time_service.dart │ │ ├── device_info_service.dart │ │ ├── file_picker_service.dart │ │ ├── local_storage_service.dart │ │ ├── location_service.dart │ │ ├── navigation_service.dart │ │ ├── notification_service.dart │ │ ├── url_service.dart │ │ └── user_data_service.dart │ └── theme │ │ ├── app_colors.dart │ │ └── custom_theme.dart ├── firebase_options.dart ├── locator.dart ├── main.dart └── ui │ ├── custom_widgets │ ├── bottom_nav_bar │ │ └── fab_bar.dart │ ├── dialogs │ │ ├── auth_dialog.dart │ │ ├── network_error_dialog.dart │ │ ├── request_failed_dialog.dart │ │ └── request_success_dialog.dart │ ├── gender_radio_group.dart │ ├── image_container.dart │ ├── shimmer.dart │ ├── single_radio_button.dart │ └── text_fields │ │ └── custom_text_field.dart │ └── screens │ ├── authentication │ ├── forget_password │ │ ├── forget_password_screen.dart │ │ └── forget_password_view_model.dart │ ├── login_screen │ │ ├── login_screen.dart │ │ └── login_view_model.dart │ └── signup_screen │ │ ├── signup_screen.dart │ │ └── signup_view_model.dart │ ├── home_screen │ ├── home_screen.dart │ └── home_screen_view_model.dart │ ├── navigation │ ├── navigation_screen.dart │ └── navigation_view_model.dart │ ├── onboarding │ ├── onboarding_screen.dart │ └── onboarding_view_model.dart │ ├── pin_location │ ├── pin_location_screen.dart │ └── pin_location_view_model.dart │ └── splash_screen.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 ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ └── app_icon_64.png │ ├── Base.lproj │ │ └── MainMenu.xib │ ├── Configs │ │ ├── AppInfo.xcconfig │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── GoogleService-Info.plist │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements └── firebase_app_id_file.json ├── pubspec.lock ├── pubspec.yaml ├── web ├── favicon.png ├── 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 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: eb6d86ee27deecba4a83536aa20f366a6044895c 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 17 | base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 18 | - platform: android 19 | create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 20 | base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 21 | - platform: ios 22 | create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 23 | base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 24 | - platform: linux 25 | create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 26 | base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 27 | - platform: macos 28 | create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 29 | base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 30 | - platform: web 31 | create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 32 | base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 33 | - platform: windows 34 | create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 35 | base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mvvm_template 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /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 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /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/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | // START: FlutterFire Configuration 26 | apply plugin: 'com.google.gms.google-services' 27 | apply plugin: 'com.google.firebase.firebase-perf' 28 | apply plugin: 'com.google.firebase.crashlytics' 29 | // END: FlutterFire Configuration 30 | apply plugin: 'kotlin-android' 31 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 32 | 33 | android { 34 | compileSdkVersion flutter.compileSdkVersion 35 | ndkVersion flutter.ndkVersion 36 | 37 | compileOptions { 38 | sourceCompatibility JavaVersion.VERSION_1_8 39 | targetCompatibility JavaVersion.VERSION_1_8 40 | } 41 | 42 | kotlinOptions { 43 | jvmTarget = '1.8' 44 | } 45 | 46 | sourceSets { 47 | main.java.srcDirs += 'src/main/kotlin' 48 | } 49 | 50 | defaultConfig { 51 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 52 | applicationId "com.example.mvvm_template" 53 | // You can update the following values to match your application needs. 54 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 55 | minSdkVersion flutter.minSdkVersion 56 | targetSdkVersion flutter.targetSdkVersion 57 | versionCode flutterVersionCode.toInteger() 58 | versionName flutterVersionName 59 | } 60 | 61 | buildTypes { 62 | release { 63 | // TODO: Add your own signing config for the release build. 64 | // Signing with the debug keys for now, so `flutter run --release` works. 65 | signingConfig signingConfigs.debug 66 | } 67 | } 68 | } 69 | 70 | flutter { 71 | source '../..' 72 | } 73 | 74 | dependencies { 75 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 76 | } 77 | -------------------------------------------------------------------------------- /android/app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "504449834445", 4 | "project_id": "mvvm-template-apptex", 5 | "storage_bucket": "mvvm-template-apptex.appspot.com" 6 | }, 7 | "client": [ 8 | { 9 | "client_info": { 10 | "mobilesdk_app_id": "1:504449834445:android:152165f721d869d0afb884", 11 | "android_client_info": { 12 | "package_name": "com.example.mvvm_template" 13 | } 14 | }, 15 | "oauth_client": [ 16 | { 17 | "client_id": "504449834445-95g3imoimm81kcnt8ur6gor90paq40d2.apps.googleusercontent.com", 18 | "client_type": 3 19 | } 20 | ], 21 | "api_key": [ 22 | { 23 | "current_key": "AIzaSyAbJNhCm5SEir-NYpkrg1m3Flj5pxGERDk" 24 | } 25 | ], 26 | "services": { 27 | "appinvite_service": { 28 | "other_platform_oauth_client": [ 29 | { 30 | "client_id": "504449834445-95g3imoimm81kcnt8ur6gor90paq40d2.apps.googleusercontent.com", 31 | "client_type": 3 32 | } 33 | ] 34 | } 35 | } 36 | } 37 | ], 38 | "configuration_version": "1" 39 | } -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/mvvm_template/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.mvvm_template 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | // START: FlutterFire Configuration 11 | classpath 'com.google.gms:google-services:4.3.10' 12 | classpath 'com.google.firebase:perf-plugin:1.4.1' 13 | classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1' 14 | // END: FlutterFire Configuration 15 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | google() 22 | mavenCentral() 23 | } 24 | } 25 | 26 | rootProject.buildDir = '../build' 27 | subprojects { 28 | project.buildDir = "${rootProject.buildDir}/${project.name}" 29 | } 30 | subprojects { 31 | project.evaluationDependsOn(':app') 32 | } 33 | 34 | task clean(type: Delete) { 35 | delete rootProject.buildDir 36 | } 37 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 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-7.4-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /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 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.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 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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/GoogleService-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CLIENT_ID 6 | 504449834445-krdr51q5p2g13sdqn3qunj3irkc8o858.apps.googleusercontent.com 7 | REVERSED_CLIENT_ID 8 | com.googleusercontent.apps.504449834445-krdr51q5p2g13sdqn3qunj3irkc8o858 9 | API_KEY 10 | AIzaSyAMB1jzMjV-reKKlWSjo3NhC1mC6n1XTxM 11 | GCM_SENDER_ID 12 | 504449834445 13 | PLIST_VERSION 14 | 1 15 | BUNDLE_ID 16 | com.example.mvvmTemplate 17 | PROJECT_ID 18 | mvvm-template-apptex 19 | STORAGE_BUCKET 20 | mvvm-template-apptex.appspot.com 21 | IS_ADS_ENABLED 22 | 23 | IS_ANALYTICS_ENABLED 24 | 25 | IS_APPINVITE_ENABLED 26 | 27 | IS_GCM_ENABLED 28 | 29 | IS_SIGNIN_ENABLED 30 | 31 | GOOGLE_APP_ID 32 | 1:504449834445:ios:f920537a3e69af86afb884 33 | 34 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Mvvm Template 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | mvvm_template 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /ios/firebase_app_id_file.json: -------------------------------------------------------------------------------- 1 | { 2 | "file_generated_by": "FlutterFire CLI", 3 | "purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory", 4 | "GOOGLE_APP_ID": "1:504449834445:ios:f920537a3e69af86afb884", 5 | "FIREBASE_PROJECT_ID": "mvvm-template-apptex", 6 | "GCM_SENDER_ID": "504449834445" 7 | } -------------------------------------------------------------------------------- /lib/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 | import 'package:mvvm_template/core/Routes/route_generator.dart'; 4 | import 'package:mvvm_template/core/Routes/routes.dart'; 5 | import 'package:mvvm_template/core/services/navigation_service.dart'; 6 | import 'package:mvvm_template/core/theme/custom_theme.dart'; 7 | 8 | class MyApp extends StatelessWidget { 9 | final String title; 10 | 11 | //TODO update the _designWidth and _designHeight according to your figma design 12 | static const double _designWidth = 375; 13 | static const double _designHeight = 812; 14 | const MyApp({required this.title, Key? key}) : super(key: key); 15 | @override 16 | Widget build(BuildContext context) { 17 | return ScreenUtilInit( 18 | designSize: const Size(_designWidth, _designHeight), 19 | builder: (context, widget) => MaterialApp( 20 | navigatorKey: NavigationService.navigatorKey, 21 | onGenerateRoute: RouteGenerator.generateRoute, 22 | locale: const Locale("en"), 23 | title: title, 24 | theme: CustomTheme.lightTheme, 25 | themeMode: ThemeMode.light, 26 | initialRoute: AppRoutes.splashScreenRoute, 27 | debugShowCheckedModeBanner: false, 28 | ), 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/core/Routes/route_generator.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mvvm_template/core/Routes/routes.dart'; 3 | import 'package:mvvm_template/core/constants/styles.dart'; 4 | import 'package:mvvm_template/core/others/logger_customization/custom_logger.dart'; 5 | import 'package:mvvm_template/ui/screens/authentication/forget_password/forget_password_screen.dart'; 6 | import 'package:mvvm_template/ui/screens/authentication/login_screen/login_screen.dart'; 7 | import 'package:mvvm_template/ui/screens/navigation/navigation_screen.dart'; 8 | import 'package:mvvm_template/ui/screens/onboarding/onboarding_screen.dart'; 9 | import 'package:mvvm_template/ui/screens/splash_screen.dart'; 10 | 11 | class RouteGenerator { 12 | static final log = CustomLogger(className: 'RouteGenerator'); 13 | static Route generateRoute(RouteSettings settings) { 14 | final arguments = settings.arguments; 15 | 16 | log.wtf("@RouteGenerator/generateRoute ${settings.name}"); 17 | switch (settings.name) { 18 | case "/": 19 | return MaterialPageRoute( 20 | settings: settings, 21 | builder: (_) => const LoginScreen(), 22 | ); 23 | case AppRoutes.loginRoute: 24 | arguments; 25 | return MaterialPageRoute( 26 | settings: settings, 27 | builder: (_) => const LoginScreen(), 28 | ); 29 | case AppRoutes.splashScreenRoute: 30 | arguments; 31 | return MaterialPageRoute( 32 | settings: settings, 33 | builder: (_) => const SplashScreen(), 34 | ); 35 | case AppRoutes.onboardingRoute: 36 | var providedArguments = arguments as dynamic; 37 | return MaterialPageRoute( 38 | settings: settings, 39 | builder: (_) => OnboardingScreen( 40 | onboardingList: providedArguments.onboardingList, 41 | preCachedImages: providedArguments.preCachedImages, 42 | currentIndex: providedArguments.currentIndex, 43 | ), 44 | ); 45 | case AppRoutes.navigationRoute: 46 | arguments; 47 | return MaterialPageRoute( 48 | settings: settings, 49 | builder: (_) => const NavigationScreen(), 50 | ); 51 | case AppRoutes.forgotPasswordRoute: 52 | arguments; 53 | return MaterialPageRoute( 54 | settings: settings, 55 | builder: (_) => const ForgetPasswordScreen(), 56 | ); 57 | 58 | //TODO add all the routes here 59 | } 60 | 61 | log.wtf( 62 | "@RouteGenerator/generateRoute Error : Route not defined => (${settings.name})"); 63 | return MaterialPageRoute( 64 | settings: settings, 65 | builder: (context) => Scaffold( 66 | body: Container( 67 | color: Colors.red, 68 | height: MediaQuery.of(context).size.height, 69 | width: MediaQuery.of(context).size.width, 70 | child: Center( 71 | child: Text( 72 | "Route Error : Route not defined", 73 | style: myStyle(12, true, color: Colors.white), 74 | ), 75 | ), 76 | ), 77 | ), 78 | ); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /lib/core/Routes/routes.dart: -------------------------------------------------------------------------------- 1 | class AppRoutes { 2 | static const splashScreenRoute = '/splash-screen'; 3 | static const loginRoute = '/login-screen'; 4 | static const signUpRoute = '/signup-screen'; 5 | static const onboardingRoute = '/onboarding-screen'; 6 | static const navigationRoute = '/navigation-screen'; 7 | static const forgotPasswordRoute = '/forgot-password-screen'; 8 | static const homePageRoute = '/home'; 9 | static const profilePageRoute = '/profile'; 10 | static const settingsPageRoute = '/settings'; 11 | static const notificationsPageRoute = '/notifications'; 12 | static const aboutPageRoute = '/about'; 13 | } 14 | -------------------------------------------------------------------------------- /lib/core/config/config.dart: -------------------------------------------------------------------------------- 1 | import 'package:mvvm_template/core/enums/env.dart'; 2 | 3 | class Config { 4 | final Env _env; 5 | final String _devBaseUrl = ''; 6 | final String _testBaseUrl = ''; 7 | final String _productionBaseUrl = ''; 8 | late String _baseUrl; 9 | 10 | 11 | /// Getters 12 | Env get env => _env; 13 | String get baseUrl => _baseUrl; 14 | 15 | /// Constructor 16 | Config(this._env) { 17 | _setupBaseUrl(); 18 | } 19 | 20 | _setupBaseUrl() { 21 | if (_env == Env.production) { 22 | _baseUrl = _productionBaseUrl; 23 | } else if (_env == Env.production) { 24 | _baseUrl = _testBaseUrl; 25 | } else if (_env == Env.production) { 26 | _baseUrl = _devBaseUrl; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/core/constants/api_end_points.dart: -------------------------------------------------------------------------------- 1 | class EndPoints { 2 | static const userProfile = 'user_profile'; 3 | static const onboardingData = 'onboarding_data'; 4 | static const fcmToken = 'fcm_token'; 5 | static const clearFcmToken = 'clear_fcm_token'; 6 | static const login = 'login'; 7 | static const signUp = 'sign_up'; 8 | static const resetPassword = 'reset_password'; 9 | } 10 | -------------------------------------------------------------------------------- /lib/core/constants/constants.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mvvm_template/core/constants/strings.dart'; 3 | import 'package:mvvm_template/core/theme/app_colors.dart'; 4 | 5 | class Constants { 6 | static Images appImages = Images(); 7 | static AppIcons appIcons = AppIcons(); 8 | static AppShadows appShadows = AppShadows(); 9 | } 10 | 11 | class Images { 12 | final String loginBackground = '$assetsPath/images/login_bg.png'; 13 | } 14 | 15 | class AppIcons { 16 | final String appLogo = '$assetsPath/icons/logo.png'; 17 | final String overview = '$assetsPath/icons/overview.png'; 18 | final String users = '$assetsPath/icons/users.png'; 19 | final String caregivers = '$assetsPath/icons/caregivers.png'; 20 | final String document = '$assetsPath/icons/document.png'; 21 | final String dollar = '$assetsPath/icons/dollar.png'; 22 | final String bottomHomeIcon = "$assetsPath/bottom_home_icon.png"; 23 | final String bottomCardIcon = "${assetsPath}bottom_card_icon.png"; 24 | final String bottomCategoryIcon = "${assetsPath}bottom_category_icon.png"; 25 | final String bottomProfileIcon = "${assetsPath}bottom_profile_icon.png"; 26 | } 27 | 28 | class AppShadows { 29 | final List cardShadow = [ 30 | BoxShadow( 31 | color: AppColors.blackColor.withOpacity(0.05), 32 | spreadRadius: -1, 33 | blurRadius: 8, 34 | offset: const Offset(0, 5), 35 | ) 36 | ]; 37 | final BoxShadow backButtonShadow = const BoxShadow( 38 | color: AppColors.greyColor, 39 | spreadRadius: 2, 40 | blurRadius: 30, 41 | blurStyle: BlurStyle.normal, 42 | offset: Offset(0, 2), 43 | ); 44 | 45 | final BoxShadow inputFieldShadow = const BoxShadow( 46 | color: AppColors.greyColor, 47 | spreadRadius: 10, 48 | blurRadius: 30, 49 | blurStyle: BlurStyle.normal, 50 | offset: Offset(0, 2), 51 | ); 52 | } 53 | -------------------------------------------------------------------------------- /lib/core/constants/strings.dart: -------------------------------------------------------------------------------- 1 | //TODO put all the constant strings here 2 | 3 | const String assetsPath = "assets"; 4 | 5 | const welcomeMsg = 'Welcome message'; 6 | -------------------------------------------------------------------------------- /lib/core/constants/styles.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:google_fonts/google_fonts.dart'; 3 | 4 | //TODO put all the custom text styles here 5 | 6 | TextStyle myStyle( 7 | double size, 8 | bool isBold, { 9 | Color color = Colors.black, 10 | FontWeight? overrideBold = FontWeight.bold, 11 | }) { 12 | return GoogleFonts.lato( 13 | fontSize: size, 14 | fontWeight: (isBold) ? overrideBold : FontWeight.normal, 15 | color: color); 16 | } 17 | -------------------------------------------------------------------------------- /lib/core/enums/env.dart: -------------------------------------------------------------------------------- 1 | enum Env { dev, test, production } 2 | -------------------------------------------------------------------------------- /lib/core/enums/view_state.dart: -------------------------------------------------------------------------------- 1 | /// 2 | /// [idle] : When data is ready to renders on the UI. 3 | /// 4 | /// [busy] : When there is some process(loading data, performing 5 | /// any time taking task) going on and to block new process requests. 6 | /// 7 | enum ViewState { 8 | idle, 9 | busy, 10 | loading, 11 | } 12 | -------------------------------------------------------------------------------- /lib/core/extensions/double_extensions.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | extension DoubleExtension on double { 4 | /// Rounds the double to a specific decimal place 5 | double roundedPrecision(int places) { 6 | double mod = pow(10.0, places) as double; 7 | return ((this * mod).round().toDouble() / mod); 8 | } 9 | 10 | /// good for string output because it can remove trailing zeros 11 | /// and sometimes periods. Or optionally display the exact number of trailing 12 | /// zeros 13 | /// Format: input number: 1234567, Output: 1,234,567 14 | String roundedPrecisionToString( 15 | int places, { 16 | bool trailingZeros = false, 17 | }) { 18 | double mod = pow(10.0, places) as double; 19 | double round = ((this * mod).round().toDouble() / mod); 20 | String doubleToString = 21 | trailingZeros ? round.toStringAsFixed(places) : round.toString(); 22 | if (!trailingZeros) { 23 | RegExp trailingZeros = RegExp(r'^[0-9]+.0+$'); 24 | if (trailingZeros.hasMatch(doubleToString)) { 25 | doubleToString = doubleToString.split('.')[0]; 26 | } 27 | } 28 | 29 | RegExp reg = RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'); 30 | mathFunc(Match match) => '${match[1]},'; 31 | 32 | return doubleToString.replaceAllMapped(reg, mathFunc); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/core/models/body/login_body.dart: -------------------------------------------------------------------------------- 1 | class LoginBody { 2 | String? email; 3 | String? password; 4 | 5 | LoginBody({this.email, this.password}); 6 | 7 | toJson() => { 8 | 'email': email, 9 | 'password': password, 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /lib/core/models/body/reset_password_body.dart: -------------------------------------------------------------------------------- 1 | class ResetPasswordBody { 2 | String? email; 3 | 4 | ResetPasswordBody({ 5 | this.email, 6 | }); 7 | 8 | toJson() => {'email': email}; 9 | } 10 | -------------------------------------------------------------------------------- /lib/core/models/body/signup_body.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:dio/dio.dart' as dio; 4 | 5 | class SignUpBody { 6 | String? email; 7 | String? password; 8 | String? name; 9 | String? location; 10 | String? gender; 11 | String? phone; 12 | File? image; 13 | // String? fcmToken; 14 | 15 | /// Other fields to be added as well. 16 | SignUpBody({ 17 | this.email, 18 | this.password, 19 | this.gender, 20 | this.location, 21 | this.name, 22 | this.phone, 23 | this.image, 24 | // this.fcmToken, 25 | }); 26 | 27 | toJson() async { 28 | return { 29 | 'email': email, 30 | 'password': password, 31 | 'name': name, 32 | 'location': location, 33 | 'gender': gender, 34 | 'phone': phone, 35 | 'image': 36 | image != null ? await dio.MultipartFile.fromFile(image!.path) : null, 37 | // 'fcm_token': this.fcmToken, 38 | }; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/core/models/body/update_pasword_body.dart: -------------------------------------------------------------------------------- 1 | class UpdatePasswordBody { 2 | String? oldPassword; 3 | String? newPassword; 4 | 5 | UpdatePasswordBody({this.oldPassword, this.newPassword}); 6 | 7 | toJson() => { 8 | 'oldPassword': oldPassword, 9 | 'newPassword': newPassword, 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /lib/core/models/other/onboarding.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class Onboarding { 4 | late String? imgUrl; 5 | late String? title; 6 | 7 | Onboarding(this.imgUrl, this.title); 8 | 9 | Onboarding.fromJson(json) { 10 | debugPrint('$json'); 11 | title = json['title']; 12 | imgUrl = json['image_url']; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/core/models/responses/auth_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:mvvm_template/core/models/responses/base_responses/base_response.dart'; 2 | 3 | class AuthResponse extends BaseResponse { 4 | String? accessToken; 5 | 6 | /// Default constructor 7 | AuthResponse(success, {error, this.accessToken}) 8 | : super(success, error: error); 9 | 10 | /// Named Constructor 11 | AuthResponse.fromJson(json) : super.fromJson(json) { 12 | if (json['body'] != null) accessToken = json['body']['token']; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/core/models/responses/base_responses/base_response.dart: -------------------------------------------------------------------------------- 1 | class BaseResponse { 2 | late bool success; 3 | String? error; 4 | 5 | BaseResponse(this.success, {this.error}); 6 | 7 | BaseResponse.fromJson(json) { 8 | success = json['success']; 9 | error = json['error']; 10 | } 11 | 12 | toJson() { 13 | return { 14 | 'success': success, 15 | 'error': error, 16 | }; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/core/models/responses/base_responses/request_response.dart: -------------------------------------------------------------------------------- 1 | class RequestResponse { 2 | late bool success; 3 | String? error; 4 | late Map data; 5 | 6 | RequestResponse(this.success, {this.error}); 7 | 8 | RequestResponse.fromJson(json) { 9 | data = json; 10 | success = json['success']; 11 | error = json['error']; 12 | } 13 | 14 | toJson() { 15 | return { 16 | 'success': success, 17 | 'error': error, 18 | 'body': data, 19 | }; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/core/models/responses/onboarding_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:mvvm_template/core/models/other/onboarding.dart'; 2 | import 'package:mvvm_template/core/models/responses/base_responses/base_response.dart'; 3 | 4 | class OnboardingResponse extends BaseResponse { 5 | late List onboardingsList = []; 6 | 7 | /// Default constructor 8 | OnboardingResponse(success, {error}) : super(success, error: error); 9 | 10 | /// Named Constructor 11 | OnboardingResponse.fromJson(json) : super.fromJson(json) { 12 | if (json['body'] != null) { 13 | json['body']?['boarding']?.forEach((onboardingJson) { 14 | onboardingsList.add(Onboarding.fromJson(onboardingJson)); 15 | }); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/core/models/responses/user_profile_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:mvvm_template/core/models/responses/base_responses/base_response.dart'; 2 | import 'package:mvvm_template/core/models/user/profile.dart'; 3 | 4 | class UserProfileResponse extends BaseResponse { 5 | UserProfile? profile; 6 | 7 | UserProfileResponse(success, {error}) : super(success, error: error); 8 | 9 | UserProfileResponse.fromJson(json) : super.fromJson(json) { 10 | if (json['body'] != null) { 11 | profile = UserProfile.fromJson(json['body']['user']); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/core/models/user/profile.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart' as dio; 2 | 3 | class UserProfile { 4 | String? uid; 5 | String? name; 6 | String? email; 7 | String? fcmToken; 8 | String? emailVerifiedAt; 9 | String? phone; 10 | String? imageUrl; 11 | String? gender; 12 | String? location; 13 | String? mobile; 14 | String? dob; 15 | 16 | UserProfile( 17 | {this.name, 18 | this.email, 19 | this.fcmToken, 20 | this.emailVerifiedAt, 21 | this.phone, 22 | this.imageUrl, 23 | this.gender, 24 | this.location, 25 | this.mobile, 26 | this.dob, 27 | this.uid}); 28 | 29 | UserProfile.fromJson(Map json) { 30 | name = json['name']; 31 | email = json['email']; 32 | fcmToken = json['fcm_token']; 33 | emailVerifiedAt = json['email_verified_at']; 34 | phone = json['phone']; 35 | imageUrl = json['image_url']; 36 | gender = json['gender']; 37 | location = json['location']; 38 | dob = json['dob']; 39 | uid = json['uid']; 40 | } 41 | 42 | Future> toJson() async { 43 | final Map data = {}; 44 | data['name'] = name; 45 | data['email'] = email; 46 | // data['fcmToken'] = this.fcmToken; 47 | data['phone'] = phone; 48 | data['image'] = 49 | imageUrl != null ? await dio.MultipartFile.fromFile(imageUrl!) : null; 50 | data['gender'] = gender; 51 | data['location'] = location; 52 | data['uid'] = uid; 53 | return data; 54 | } 55 | 56 | deepCopy() { 57 | return UserProfile( 58 | name: name, 59 | email: email, 60 | fcmToken: fcmToken, 61 | phone: phone, 62 | imageUrl: imageUrl, 63 | gender: gender, 64 | location: location, 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/core/others/base_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mvvm_template/core/enums/view_state.dart'; 3 | 4 | /// 5 | /// [BaseViewModel] is the base class with all 6 | /// state related logic. 7 | /// 8 | /// [BaseViewModel] class will be extended by all viewModels. 9 | /// 10 | /// [setState] will be used to update the state of the screen 11 | /// 12 | class BaseViewModel extends ChangeNotifier { 13 | ViewState _state = ViewState.idle; 14 | 15 | ViewState get state => _state; 16 | 17 | void setState(ViewState state) { 18 | _state = state; 19 | notifyListeners(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/core/others/logger_customization/custom_log_output.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:logger/logger.dart'; 3 | 4 | class CustomLogOutput extends LogOutput { 5 | @override 6 | void output(OutputEvent event) { 7 | final color = PrettyPrinter.levelColors[event.level]; 8 | for (var line in event.lines) { 9 | debugPrint(color!(line)); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/core/others/logger_customization/custom_log_printer.dart: -------------------------------------------------------------------------------- 1 | import 'package:logger/logger.dart'; 2 | 3 | class CustomLogPrinter extends LogPrinter { 4 | final String className; 5 | CustomLogPrinter({required this.className}); 6 | 7 | final logger = Logger(); 8 | 9 | @override 10 | List log(LogEvent event) { 11 | var emoji = PrettyPrinter.levelEmojis[event.level]; 12 | return ['$emoji $className - ${event.message}']; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/core/others/logger_customization/custom_logger.dart: -------------------------------------------------------------------------------- 1 | import 'package:logger/logger.dart'; 2 | import 'package:mvvm_template/core/others/logger_customization/custom_log_output.dart'; 3 | import 'package:mvvm_template/core/others/logger_customization/custom_log_printer.dart'; 4 | 5 | class CustomLogger extends Logger { 6 | final String className; 7 | 8 | CustomLogger({required this.className}) 9 | : super( 10 | output: CustomLogOutput(), 11 | printer: CustomLogPrinter(className: className), 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /lib/core/services/api_services.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: body_might_complete_normally_catch_error 2 | 3 | import 'package:dio/dio.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mvvm_template/core/config/config.dart'; 6 | import 'package:mvvm_template/core/models/responses/base_responses/request_response.dart'; 7 | import 'package:mvvm_template/core/services/local_storage_service.dart'; 8 | import 'package:mvvm_template/locator.dart'; 9 | 10 | class ApiServices { 11 | final _config = locator(); 12 | Future launchDio() async { 13 | String? accessToken = locator().accessToken; 14 | Dio dio = Dio(); 15 | dio.interceptors.add(LogInterceptor(responseBody: true, requestBody: true)); 16 | // dio.interceptors.add( 17 | // DioCacheManager(CacheConfig(baseUrl: EndPoint.baseUrl)).interceptor); 18 | dio.options.headers['Content-Type'] = 'application/json'; 19 | dio.options.headers["accept"] = 'application/json'; 20 | dio.options.headers["Authorization"] = 'Bearer $accessToken'; 21 | 22 | dio.options.followRedirects = false; 23 | dio.options.validateStatus = (s) { 24 | if (s != null) { 25 | return s < 500; 26 | } else { 27 | return false; 28 | } 29 | }; 30 | return dio; 31 | } 32 | 33 | get({required String endPoint, params}) async { 34 | Dio dio = await launchDio(); 35 | final response = await dio 36 | .get('${_config.baseUrl}/$endPoint', queryParameters: params) 37 | .catchError((e) { 38 | debugPrint('Unexpected Error'); 39 | }); 40 | if (response.statusCode == 200) { 41 | return RequestResponse.fromJson(response.data); 42 | } else if (response.statusCode == 500) { 43 | return RequestResponse(false, error: 'Server Error'); 44 | } else { 45 | return RequestResponse(false, error: 'Network Error'); 46 | } 47 | } 48 | 49 | post({required String endPoint, data}) async { 50 | Dio dio = await launchDio(); 51 | final response = await dio 52 | .post('${_config.baseUrl}/$endPoint', data: data) 53 | .catchError((e) { 54 | debugPrint('Unexpected Error'); 55 | }); 56 | if (response.statusCode == 200) { 57 | return RequestResponse.fromJson(response.data); 58 | } else if (response.statusCode == 500) { 59 | return RequestResponse(false, error: 'Server Error'); 60 | } else { 61 | return RequestResponse(false, error: 'Network Error'); 62 | } 63 | } 64 | 65 | put({required String endPoint, data}) async { 66 | Dio dio = await launchDio(); 67 | final response = await dio 68 | .put('${_config.baseUrl}/$endPoint', data: data) 69 | .catchError((e) { 70 | debugPrint('Unexpected Error'); 71 | }); 72 | if (response.statusCode == 200) { 73 | return RequestResponse.fromJson(response.data); 74 | } else if (response.statusCode == 500) { 75 | return RequestResponse(false, error: 'Server Error'); 76 | } else { 77 | return RequestResponse(false, error: 'Network Error'); 78 | } 79 | } 80 | 81 | delete({required String endPoint, params}) async { 82 | Dio dio = await launchDio(); 83 | final response = await dio 84 | .delete('${_config.baseUrl}/$endPoint', queryParameters: params) 85 | .catchError((e) { 86 | debugPrint('Unexpected Error'); 87 | }); 88 | if (response.statusCode == 200) { 89 | return RequestResponse.fromJson(response.data); 90 | } else if (response.statusCode == 500) { 91 | return RequestResponse(false, error: 'Server Error'); 92 | } else { 93 | return RequestResponse(false, error: 'Network Error'); 94 | } 95 | } 96 | 97 | //TODO add method for uploading files 98 | } 99 | -------------------------------------------------------------------------------- /lib/core/services/authentication/custom backend/auth_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:logger/logger.dart'; 2 | import 'package:mvvm_template/core/models/body/login_body.dart'; 3 | import 'package:mvvm_template/core/models/body/reset_password_body.dart'; 4 | import 'package:mvvm_template/core/models/body/signup_body.dart'; 5 | import 'package:mvvm_template/core/models/responses/auth_response.dart'; 6 | import 'package:mvvm_template/core/models/responses/user_profile_response.dart'; 7 | import 'package:mvvm_template/core/models/user/profile.dart'; 8 | import 'package:mvvm_template/core/others/logger_customization/custom_logger.dart'; 9 | import 'package:mvvm_template/core/services/database/custom%20backend/database_service.dart'; 10 | import 'package:mvvm_template/core/services/device_info_service.dart'; 11 | import 'package:mvvm_template/core/services/local_storage_service.dart'; 12 | import 'package:mvvm_template/locator.dart'; 13 | 14 | /// 15 | /// [AuthService] class contains all authentication related logic with following 16 | /// methods: 17 | /// 18 | /// [doSetup]: This method contains all the initial authentication like checking 19 | /// login status, onboarding status and other related initial app flow setup. 20 | /// 21 | /// [signupWithEmailAndPassword]: This method is used for signup with email and password. 22 | /// 23 | /// [signupWithApple]: 24 | /// 25 | /// [signupWithGmail]: 26 | /// 27 | /// [signupWithFacebook]: 28 | /// 29 | /// [logout]: 30 | /// 31 | class AuthService { 32 | late bool isLogin; 33 | final _localStorageService = locator(); 34 | final _dbService = locator(); 35 | UserProfile? userProfile; 36 | String? fcmToken; 37 | static final Logger log = CustomLogger(className: 'AuthService'); 38 | 39 | /// 40 | /// [doSetup] Function does the following things: 41 | /// 1) Checks if the user is logged then: 42 | /// a) Get the user profile data 43 | /// b) Updates the user FCM Token 44 | /// 45 | doSetup() async { 46 | isLogin = _localStorageService.accessToken != null; 47 | if (isLogin) { 48 | log.d('User is already logged-in'); 49 | await _getUserProfile(); 50 | await _updateFcmToken(); 51 | } else { 52 | log.d('@doSetup: User is not logged-in'); 53 | } 54 | } 55 | 56 | _getUserProfile() async { 57 | UserProfileResponse response = await _dbService.getUserProfile(); 58 | if (response.success) { 59 | userProfile = response.profile; 60 | log.d('Got User Data: ${userProfile?.toJson()}'); 61 | } else { 62 | //Get.dialog(AuthDialog(title: 'Title', message: response.error!)); 63 | } 64 | } 65 | 66 | /// 67 | /// Updating FCM Token here... 68 | /// 69 | _updateFcmToken() async { 70 | //final fcmToken = await locator().getFcmToken(); 71 | final deviceId = await DeviceInfoService().getDeviceId(); 72 | final response = await _dbService.updateFcmToken(deviceId, fcmToken!); 73 | if (response.success) { 74 | userProfile!.fcmToken = fcmToken; 75 | } 76 | } 77 | 78 | signupWithEmailAndPassword(SignUpBody body) async { 79 | late AuthResponse response; 80 | response = await _dbService.createAccount(body); 81 | if (response.success) { 82 | userProfile = UserProfile.fromJson(body.toJson()); 83 | _localStorageService.accessToken = response.accessToken; 84 | await _updateFcmToken(); 85 | } 86 | return response; 87 | } 88 | 89 | loginWithEmailAndPassword(LoginBody body) async { 90 | late AuthResponse response; 91 | response = await _dbService.loginWithEmailAndPassword(body); 92 | if (response.success) { 93 | _localStorageService.accessToken = response.accessToken; 94 | await _getUserProfile(); 95 | _updateFcmToken(); 96 | } 97 | return response; 98 | } 99 | 100 | resetPassword(ResetPasswordBody body) async { 101 | final AuthResponse response = await _dbService.resetPassword(body); 102 | if (response.success) { 103 | _localStorageService.accessToken = response.accessToken; 104 | } 105 | return response; 106 | } 107 | 108 | signupWithApple() {} 109 | 110 | signupWithGmail() {} 111 | 112 | signupWithFacebook() {} 113 | 114 | logout() async { 115 | isLogin = false; 116 | userProfile = null; 117 | await _dbService.clearFcmToken(await DeviceInfoService().getDeviceId()); 118 | _localStorageService.accessToken = null; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /lib/core/services/database/custom backend/database_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:mvvm_template/core/constants/api_end_points.dart'; 2 | import 'package:mvvm_template/core/models/body/login_body.dart'; 3 | import 'package:mvvm_template/core/models/body/reset_password_body.dart'; 4 | import 'package:mvvm_template/core/models/body/signup_body.dart'; 5 | import 'package:mvvm_template/core/models/responses/auth_response.dart'; 6 | import 'package:mvvm_template/core/models/responses/base_responses/base_response.dart'; 7 | import 'package:mvvm_template/core/models/responses/base_responses/request_response.dart'; 8 | import 'package:mvvm_template/core/models/responses/onboarding_response.dart'; 9 | import 'package:mvvm_template/core/models/responses/user_profile_response.dart'; 10 | import 'package:mvvm_template/core/services/api_services.dart'; 11 | import 'package:mvvm_template/locator.dart'; 12 | 13 | class DatabaseService { 14 | final ApiServices _apiServices = locator(); 15 | 16 | Future getUserProfile() async { 17 | final RequestResponse response = 18 | await _apiServices.get(endPoint: EndPoints.userProfile); 19 | return UserProfileResponse.fromJson(response.data); 20 | } 21 | 22 | Future getOnboardingData() async { 23 | final RequestResponse response = 24 | await _apiServices.get(endPoint: EndPoints.onboardingData); 25 | return OnboardingResponse.fromJson(response.data); 26 | } 27 | 28 | Future updateFcmToken(String deviceId, String token) async { 29 | final RequestResponse response = await _apiServices.post( 30 | endPoint: EndPoints.fcmToken, 31 | data: { 32 | 'device_id': deviceId, 33 | 'token': token, 34 | }, 35 | ); 36 | return BaseResponse.fromJson(response.data); 37 | } 38 | 39 | Future clearFcmToken(String deviceId) async { 40 | final RequestResponse response = await _apiServices.post( 41 | endPoint: EndPoints.clearFcmToken, 42 | data: {'device_id': deviceId}, 43 | ); 44 | return BaseResponse.fromJson(response.data); 45 | } 46 | 47 | Future loginWithEmailAndPassword(LoginBody body) async { 48 | final RequestResponse response = await _apiServices.post( 49 | endPoint: EndPoints.login, 50 | data: body.toJson(), 51 | ); 52 | return AuthResponse.fromJson(response.data); 53 | } 54 | 55 | Future createAccount(SignUpBody body) async { 56 | final RequestResponse response = await _apiServices.post( 57 | endPoint: EndPoints.signUp, 58 | data: body.toJson(), 59 | ); 60 | return AuthResponse.fromJson(response.data); 61 | } 62 | 63 | Future resetPassword(ResetPasswordBody body) async { 64 | final RequestResponse response = await _apiServices.post( 65 | endPoint: EndPoints.resetPassword, 66 | data: body.toJson(), 67 | ); 68 | return AuthResponse.fromJson(response.data); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/core/services/database/firestore/firebase_db_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:cloud_firestore/cloud_firestore.dart'; 4 | import 'package:firebase_storage/firebase_storage.dart'; 5 | import 'package:mvvm_template/core/models/user/profile.dart'; 6 | 7 | class FirebaseService { 8 | //TODO update all the references according to your database structure 9 | final CollectionReference usersReference = 10 | FirebaseFirestore.instance.collection('Users'); 11 | final CollectionReference adminReference = 12 | FirebaseFirestore.instance.collection('Admin'); 13 | final CollectionReference appointmentsReference = 14 | FirebaseFirestore.instance.collection('Appointments'); 15 | final CollectionReference sellReference = 16 | FirebaseFirestore.instance.collection('Sells'); 17 | final CollectionReference chatsReference = 18 | FirebaseFirestore.instance.collection('Chats'); 19 | final CollectionReference complainsReference = 20 | FirebaseFirestore.instance.collection('Complains'); 21 | 22 | ///Uploads the [UserProfile] data to the users collection and returns docId 23 | /// 24 | ///**Important**: This function assumes that you have not set the uid 25 | ///for the user, it creates a document first, fetches the id of the document, 26 | ///assigns the docId to the uid and then uploads the data to the newly created document 27 | Future uploadUserData(UserProfile user) async { 28 | var docRef = usersReference.doc(); 29 | user.uid = docRef.id; 30 | await usersReference.doc(user.uid).set(user.toJson()); 31 | return docRef.id; 32 | } 33 | 34 | ///Updates the [fields] provided to the function for the given user 35 | /// 36 | ///**Important**: This function can be used to update any number of fields 37 | Future updateUserInfo(String uid, Map fields) async { 38 | return await usersReference.doc(uid).update(fields); 39 | } 40 | 41 | ///Returns a [UserProfile] for the given [uid] 42 | Future getUserData(String uid) async { 43 | var docSnap = await usersReference.doc(uid).get(); 44 | return UserProfile.fromJson(docSnap.data() as Map); 45 | } 46 | 47 | ///Updates the [fcm] token for the given [uid] 48 | /// 49 | ///**Important**: This function assumes that the field name is "fcmToken". 50 | ///Change it if you have named it something else 51 | Future updateFCMToken(String uid, String? fcm) async { 52 | await usersReference.doc(uid).update({ 53 | 'fcmToken': fcm, 54 | }); 55 | } 56 | 57 | ///Returns a [Stream] of all the [UserProfile] accounts in the users collection 58 | Stream> getAllUsersStream() { 59 | Stream> stream = usersReference.snapshots(); 60 | 61 | var result = stream.map((qSnap) => qSnap.docs 62 | .map((doc) => UserProfile.fromJson(doc.data() as Map)) 63 | .toList()); 64 | 65 | return result; 66 | } 67 | 68 | ///Returns a [Stream] of [UserProfile] for the given [uid] 69 | Stream getUserDataStream(String uid) { 70 | Stream> stream = 71 | usersReference.doc(uid).snapshots(); 72 | 73 | var result = stream.map((docSnap) => 74 | UserProfile.fromJson(docSnap.data() as Map)); 75 | 76 | return result; 77 | } 78 | 79 | ///Uploads the [file] to the given [path] in [FirebaseStorage] and 80 | ///returns the downloadUrl for the [file] 81 | Future uploadFile(File file, String path) async { 82 | FirebaseStorage storage = FirebaseStorage.instanceFor(); 83 | Reference firebaseStorageRef = storage.ref().child(path); 84 | UploadTask uploadTask = firebaseStorageRef.putFile(file); 85 | String downloadUrl = 86 | await uploadTask.then((taskSnap) => taskSnap.ref.getDownloadURL()); 87 | return downloadUrl; 88 | } 89 | 90 | ///Deletes the data of the [uid] user 91 | Future deleteUserData(String uid) async { 92 | return usersReference.doc(uid).delete(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/core/services/date_time_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:intl/intl.dart'; 2 | 3 | ///[DateTimeService] contains all the date formating functions 4 | class DateTimeService { 5 | ///formats the date in Year-Month-Day form 6 | static formateDate(DateTime? dateTime) { 7 | final dateFormat = DateFormat('dd MMM yyyy'); 8 | if (dateTime != null) return dateFormat.format(dateTime); 9 | } 10 | 11 | ///formats the date in [time][AM/PM] form 12 | static formatToAMPM(DateTime? dateTime) { 13 | final dateFormat = DateFormat.jm(); 14 | if (dateTime != null) return dateFormat.format(dateTime); 15 | } 16 | 17 | static myFormat(DateTime? dateTime) { 18 | final dateFormat = DateFormat('hh:mm a, dd MMM yyyy'); 19 | if (dateTime != null) { 20 | return dateFormat.format(dateTime); 21 | } 22 | } 23 | 24 | static myFormat2(DateTime? startTime, DateTime? endTime) { 25 | final timeFormat = DateFormat('hh:mm a'); 26 | final dateFormat = DateFormat('dd MMM yyyy'); 27 | if (startTime != null && endTime != null) { 28 | return "${timeFormat.format(startTime)} - ${timeFormat.format(endTime)}, ${dateFormat.format(startTime)}"; 29 | } 30 | } 31 | 32 | static String? dayName(DateTime date1, DateTime date2) { 33 | var d1 = DateTime(date1.year, date1.month, date1.day); 34 | var d2 = DateTime(date2.year, date2.month, date2.day); 35 | if (d1.difference(d2).inDays == 0) { 36 | return 'Today'; 37 | } else if (d1.difference(d2.add(const Duration(days: 1))).inDays == 0) { 38 | return 'Tomorrow'; 39 | } else { 40 | return null; 41 | } 42 | } 43 | 44 | static formatForTask(DateTime dateTime) { 45 | String? date = dayName(dateTime, DateTime.now()); 46 | 47 | final timeFormat = DateFormat('hh:mm a'); 48 | final dateFormat = DateFormat('dd MMM yyyy'); 49 | return "${date ?? dateFormat.format(dateTime)} At ${timeFormat.format(dateTime)}"; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/core/services/device_info_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:device_info/device_info.dart'; 4 | 5 | class DeviceInfoService { 6 | final deviceInfo = DeviceInfoPlugin(); 7 | 8 | ///returns the device id 9 | Future getDeviceId() async { 10 | if (Platform.isIOS) { 11 | var iosDeviceInfo = await deviceInfo.iosInfo; 12 | return iosDeviceInfo.identifierForVendor; // unique ID on iOS 13 | } else { 14 | var androidDeviceInfo = await deviceInfo.androidInfo; 15 | return androidDeviceInfo.androidId; // unique ID on Android 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/core/services/local_storage_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:mvvm_template/core/others/logger_customization/custom_logger.dart'; 2 | import 'package:shared_preferences/shared_preferences.dart'; 3 | 4 | class LocalStorageService { 5 | final log = CustomLogger(className: 'Local Storage Service'); 6 | static SharedPreferences? _preferences; 7 | 8 | /// 9 | /// List of const keys 10 | /// 11 | static const String onboardingCountKey = 'onBoardingCount'; 12 | static const String notificationsCountKey = 'notificationsCount'; 13 | static const String accessTokenKey = 'accessToken'; 14 | static const String refreshTokenKey = 'refreshToken'; 15 | 16 | /// 17 | /// Setters and getters 18 | /// 19 | int get onBoardingPageCount => _getFromDisk(onboardingCountKey) ?? 0; 20 | set onBoardingPageCount(int count) => _saveToDisk(onboardingCountKey, count); 21 | 22 | int get setNotificationsCount => _getFromDisk(notificationsCountKey) ?? 0; 23 | set setNotificationsCount(int count) => 24 | _saveToDisk(notificationsCountKey, count); 25 | 26 | dynamic get accessToken => _getFromDisk(accessTokenKey); 27 | set accessToken(token) => _saveToDisk(accessTokenKey, token); 28 | 29 | dynamic get refreshToken => _getFromDisk(refreshTokenKey); 30 | 31 | /// 32 | ///initializing instance 33 | /// 34 | init() async { 35 | _preferences = await SharedPreferences.getInstance(); 36 | } 37 | 38 | ///gets the value of [key] from disk 39 | dynamic _getFromDisk(String key) { 40 | var value = _preferences!.get(key); 41 | log.d('@_getFromDisk. key: $key value: $value'); 42 | return value; 43 | } 44 | 45 | ///saves the [content] to disk with the given [key] 46 | void _saveToDisk(String key, T? content) { 47 | log.d('@_saveToDisk. key: $key value: $content'); 48 | 49 | if (content is String) { 50 | _preferences!.setString(key, content); 51 | } 52 | if (content is bool) { 53 | _preferences!.setBool(key, content); 54 | } 55 | if (content is int) { 56 | _preferences!.setInt(key, content); 57 | } 58 | if (content is double) { 59 | _preferences!.setDouble(key, content); 60 | } 61 | if (content is List) { 62 | _preferences!.setStringList(key, content); 63 | } 64 | 65 | if (content == null) { 66 | _preferences!.remove(key); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /lib/core/services/location_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:geocoding/geocoding.dart'; 2 | import 'package:geolocator/geolocator.dart'; 3 | import 'package:google_maps_flutter/google_maps_flutter.dart'; 4 | import 'package:logger/logger.dart'; 5 | import 'package:mvvm_template/core/others/logger_customization/custom_logger.dart'; 6 | // import 'package:mvvm_template/core/services/navigation_service.dart'; 7 | // import 'package:mvvm_template/locator.dart'; 8 | import 'package:permission_handler/permission_handler.dart'; 9 | 10 | class LocationService { 11 | Position? currentLocation; 12 | double? latitude; 13 | double? longitude; 14 | final Logger log = CustomLogger(className: 'LocationService'); 15 | //final NavigationService _navigationScreen = locator(); 16 | 17 | ///returns [Position] for the current location 18 | Future getCurrentLocation() async { 19 | currentLocation = await Geolocator.getCurrentPosition(); 20 | if (currentLocation == null) { 21 | await checkPermissionStatus(); 22 | //await checkGpsService(); 23 | } 24 | log.d( 25 | 'Latitude: ${currentLocation!.latitude}, Longitude: ${currentLocation!.longitude}'); 26 | return currentLocation; 27 | } 28 | 29 | ///checks the location permission and requests permission if not granted 30 | checkPermissionStatus() async { 31 | LocationPermission permission = await checkPermissionStatus(); 32 | if (permission == LocationPermission.denied || 33 | permission == LocationPermission.deniedForever) { 34 | await Permission.location.request(); 35 | } 36 | } 37 | 38 | // checkGpsService() async { 39 | // if (await Geolocator.isLocationServiceEnabled()) { 40 | // Get.defaultDialog( 41 | // title: 'GPS is Disabled', 42 | // middleText: 'Please turn on your GPS Location', 43 | // textConfirm: 'TURN ON', 44 | // onConfirm: () async { 45 | // await Geolocator.openLocationSettings(); 46 | // Get.back(); 47 | // }, 48 | // textCancel: 'Skip', 49 | // onCancel: () {}); 50 | // } 51 | // } 52 | 53 | ///returns the address for the provided [LatLng] 54 | Future getAddressFromLatLng(LatLng? location) async { 55 | try { 56 | List placeMarks = await placemarkFromCoordinates( 57 | location!.latitude, location.longitude); 58 | 59 | Placemark place = placeMarks[0]; 60 | log.d("the location is ${place.thoroughfare} " 61 | " ${place.subLocality}" 62 | " ${place.locality}" 63 | " ${place.country}"); 64 | return "${place.thoroughfare} ${place.subLocality} ${place.locality} ${place.country}"; 65 | } catch (e) { 66 | log.d("the exception is $e"); 67 | return ''; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/core/services/navigation_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class NavigationService { 4 | static GlobalKey navigatorKey = GlobalKey(); 5 | 6 | /// Navigate to a new route without replacing the current route. No context required 7 | /// [routeName] is the name of the route to navigate to 8 | /// [arguments] is the arguments to pass to the route 9 | navigateTo(String routeName, {dynamic arguments}) { 10 | return navigatorKey.currentState 11 | ?.pushNamed(routeName, arguments: arguments); 12 | } 13 | 14 | /// Remove the current route from stack 15 | /// [value] is the value to return to the previous route 16 | pop(value) { 17 | return navigatorKey.currentState?.pop(value); 18 | } 19 | 20 | /// Remove the current route from stack without returning a value 21 | goBack() { 22 | return navigatorKey.currentState?.pop(); 23 | } 24 | 25 | /// Remove all routes from stack until the [desiredRoute] is reached 26 | popUntil(String desiredRoute) { 27 | return navigatorKey.currentState?.popUntil((route) { 28 | return route.settings.name == desiredRoute; 29 | }); 30 | } 31 | 32 | pushNamedAndRemoveUntil(route, popToInitial) { 33 | return navigatorKey.currentState?.pushNamedAndRemoveUntil( 34 | route, 35 | (Route route) => popToInitial, 36 | ); 37 | } 38 | 39 | /// Navigate to a new route replacing the current route. No context required 40 | /// [desiredRoute] is the name of the route to navigate to 41 | /// [arguments] is the arguments to pass to the route 42 | pushReplacementNamed(String desiredRoute, {dynamic arguments}) { 43 | return navigatorKey.currentState 44 | ?.pushReplacementNamed(desiredRoute, arguments: arguments); 45 | } 46 | 47 | /// Get the current context anywhere you want 48 | BuildContext getNavigationContext() { 49 | return navigatorKey.currentState!.context; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/core/services/url_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:url_launcher/url_launcher.dart'; 2 | 3 | class UrlService { 4 | static launchURL(String url) async { 5 | final uri = Uri.parse(url); 6 | if (await canLaunchUrl(uri)) { 7 | await launchUrl(uri); 8 | return true; 9 | } else { 10 | return false; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/core/services/user_data_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:mvvm_template/core/models/user/profile.dart'; 4 | import 'package:mvvm_template/core/others/logger_customization/custom_logger.dart'; 5 | import 'package:mvvm_template/core/services/authentication/firebase/fire_auth.dart'; 6 | import 'package:mvvm_template/core/services/database/firestore/firebase_db_service.dart'; 7 | import 'package:mvvm_template/locator.dart'; 8 | 9 | ///This class contains all the data that can be accessed from anywhere in the app 10 | class UserDataService { 11 | //Required services 12 | final logger = CustomLogger(className: 'UserDataService'); 13 | final _dbService = locator(); 14 | final _authService = locator(); 15 | 16 | //Variables to store user data 17 | UserProfile? userProfile; 18 | 19 | var firstTime = 20 | true; //This variables is used to listen to the streams only one time 21 | 22 | //Stream Controllers 23 | final StreamController _userProfileStreamController = 24 | StreamController.broadcast(); 25 | 26 | //Stream Getters 27 | Stream get userProfileStream => 28 | _userProfileStreamController.stream; 29 | 30 | //Stream Subscriptions 31 | StreamSubscription? _userProfileStreamSubscription; 32 | 33 | //Variable to indicate which data is loading 34 | bool userProfileIsLoading = true; 35 | 36 | initUserData() async { 37 | logger.i('@initUserData: Initialising user data'); 38 | if (firstTime) { 39 | //Initialize all the streams 40 | _userProfileStreamController.addStream( 41 | _dbService.getUserDataStream(_authService.currentUser!.uid), 42 | ); 43 | 44 | //Listen to the streams and update the variables 45 | _userProfileStreamSubscription = userProfileStream.listen((event) { 46 | userProfile = event; 47 | userProfileIsLoading = false; 48 | }); 49 | 50 | firstTime = false; 51 | } 52 | } 53 | 54 | //Dispose all the streams 55 | dispose() { 56 | _userProfileStreamSubscription?.cancel(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/core/theme/app_colors.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | //TODO update colors according to your figma design 4 | class AppColors { 5 | static const Color primaryColor = Color(0xFF35BBBB); 6 | static const Color secondaryColor = Color(0xFFF6871F); 7 | static const Color blackColor = Color(0xFF2A3333); 8 | static const Color greyColor = Color(0xFF6F7B7B); 9 | static const Color lightGreyColor = Color(0xFFEEEEEE); 10 | static const Color whiteColor = Color(0xFFFFFFFF); 11 | static const Color backgoundColor = Color(0xFFFBFBFB); 12 | static const Color errorColor = Color(0xFFF73838); 13 | static const LinearGradient gradient = LinearGradient( 14 | colors: [ 15 | Color(0xFF35BBBB), 16 | Color(0xFF35BBA2), 17 | Color.fromARGB(0, 53, 187, 187), 18 | ], 19 | transform: GradientRotation(135), 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /lib/core/theme/custom_theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:google_fonts/google_fonts.dart'; 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 4 | import 'package:mvvm_template/core/theme/app_colors.dart'; 5 | 6 | //TODO update Theme according to your figma design 7 | class CustomTheme { 8 | // Define default light and dark color themes 9 | static final ThemeData lightTheme = ThemeData( 10 | brightness: Brightness.light, 11 | primaryColor: AppColors.primaryColor, 12 | visualDensity: VisualDensity.adaptivePlatformDensity, 13 | colorScheme: const ColorScheme.light( 14 | background: AppColors.backgoundColor, 15 | brightness: Brightness.light, 16 | error: AppColors.errorColor, 17 | errorContainer: AppColors.errorColor, 18 | primary: AppColors.primaryColor, 19 | secondary: AppColors.secondaryColor, 20 | ), 21 | scaffoldBackgroundColor: AppColors.backgoundColor, 22 | buttonTheme: ButtonThemeData( 23 | buttonColor: AppColors.primaryColor, 24 | disabledColor: AppColors.greyColor, 25 | padding: EdgeInsets.symmetric(vertical: 10.sp, horizontal: 20.sp), 26 | shape: RoundedRectangleBorder( 27 | borderRadius: BorderRadius.circular(30.r), 28 | ), 29 | ), 30 | elevatedButtonTheme: ElevatedButtonThemeData( 31 | style: ElevatedButton.styleFrom( 32 | backgroundColor: AppColors.primaryColor, 33 | disabledBackgroundColor: AppColors.greyColor, 34 | foregroundColor: AppColors.whiteColor, 35 | disabledForegroundColor: AppColors.whiteColor, 36 | padding: EdgeInsets.symmetric(vertical: 25.sp, horizontal: 30.sp), 37 | textStyle: TextStyle( 38 | fontSize: 14.sp, 39 | fontWeight: FontWeight.w500, 40 | ), 41 | shape: RoundedRectangleBorder( 42 | borderRadius: BorderRadius.circular(30.r), 43 | ), 44 | ), 45 | ), 46 | textTheme: GoogleFonts.latoTextTheme( 47 | TextTheme( 48 | headlineSmall: TextStyle( 49 | color: AppColors.blackColor, 50 | fontWeight: FontWeight.w600, 51 | fontSize: 12.sp, 52 | ), 53 | headlineMedium: TextStyle( 54 | color: AppColors.blackColor, 55 | fontWeight: FontWeight.w600, 56 | fontSize: 16.sp, 57 | ), 58 | headlineLarge: TextStyle( 59 | color: AppColors.blackColor, 60 | fontWeight: FontWeight.w600, 61 | fontSize: 22.sp, 62 | ), 63 | labelSmall: TextStyle( 64 | color: AppColors.greyColor, 65 | fontWeight: FontWeight.w300, 66 | fontSize: 10.sp, 67 | ), 68 | labelMedium: TextStyle( 69 | color: AppColors.greyColor, 70 | fontWeight: FontWeight.w500, 71 | fontSize: 12.sp, 72 | ), 73 | bodySmall: TextStyle( 74 | color: AppColors.blackColor, 75 | fontWeight: FontWeight.w500, 76 | fontSize: 14.sp, 77 | ), 78 | ), 79 | ), 80 | checkboxTheme: CheckboxThemeData( 81 | fillColor: MaterialStateProperty.all(AppColors.primaryColor), 82 | checkColor: MaterialStateProperty.all(AppColors.whiteColor), 83 | shape: RoundedRectangleBorder( 84 | borderRadius: BorderRadius.circular(5.r), 85 | ), 86 | ), 87 | outlinedButtonTheme: OutlinedButtonThemeData( 88 | style: OutlinedButton.styleFrom( 89 | backgroundColor: AppColors.whiteColor, 90 | disabledBackgroundColor: AppColors.greyColor, 91 | foregroundColor: AppColors.secondaryColor, 92 | disabledForegroundColor: AppColors.whiteColor, 93 | padding: EdgeInsets.symmetric(vertical: 25.sp, horizontal: 30.sp), 94 | side: BorderSide( 95 | color: AppColors.secondaryColor, 96 | width: 1.sp, 97 | ), 98 | textStyle: TextStyle( 99 | fontSize: 14.sp, 100 | fontWeight: FontWeight.w500, 101 | ), 102 | shape: RoundedRectangleBorder( 103 | borderRadius: BorderRadius.circular(30.r), 104 | ), 105 | ), 106 | ), 107 | useMaterial3: true, 108 | ); 109 | 110 | // static final ThemeData darkTheme = ThemeData( 111 | // brightness: Brightness.dark, 112 | // primarySwatch: Colors.blue, 113 | // visualDensity: VisualDensity.adaptivePlatformDensity, 114 | // ); 115 | 116 | // Toggle between light and dark theme 117 | // static ThemeData getTheme(BuildContext context) { 118 | // if (MediaQuery.of(context).platformBrightness == Brightness.dark) { 119 | // return darkTheme; 120 | // } else { 121 | // return lightTheme; 122 | // } 123 | // } 124 | } 125 | -------------------------------------------------------------------------------- /lib/firebase_options.dart: -------------------------------------------------------------------------------- 1 | // File generated by FlutterFire CLI. 2 | // ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members 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 | return web; 21 | } 22 | switch (defaultTargetPlatform) { 23 | case TargetPlatform.android: 24 | return android; 25 | case TargetPlatform.iOS: 26 | return ios; 27 | case TargetPlatform.macOS: 28 | return macos; 29 | case TargetPlatform.windows: 30 | throw UnsupportedError( 31 | 'DefaultFirebaseOptions have not been configured for windows - ' 32 | 'you can reconfigure this by running the FlutterFire CLI again.', 33 | ); 34 | case TargetPlatform.linux: 35 | throw UnsupportedError( 36 | 'DefaultFirebaseOptions have not been configured for linux - ' 37 | 'you can reconfigure this by running the FlutterFire CLI again.', 38 | ); 39 | default: 40 | throw UnsupportedError( 41 | 'DefaultFirebaseOptions are not supported for this platform.', 42 | ); 43 | } 44 | } 45 | 46 | static const FirebaseOptions web = FirebaseOptions( 47 | apiKey: 'AIzaSyDGe49eOVerO2PjxTxcLSLBlCklEsNJuZE', 48 | appId: '1:504449834445:web:0ae012eaf831e8c8afb884', 49 | messagingSenderId: '504449834445', 50 | projectId: 'mvvm-template-apptex', 51 | authDomain: 'mvvm-template-apptex.firebaseapp.com', 52 | storageBucket: 'mvvm-template-apptex.appspot.com', 53 | ); 54 | 55 | static const FirebaseOptions android = FirebaseOptions( 56 | apiKey: 'AIzaSyAbJNhCm5SEir-NYpkrg1m3Flj5pxGERDk', 57 | appId: '1:504449834445:android:152165f721d869d0afb884', 58 | messagingSenderId: '504449834445', 59 | projectId: 'mvvm-template-apptex', 60 | storageBucket: 'mvvm-template-apptex.appspot.com', 61 | ); 62 | 63 | static const FirebaseOptions ios = FirebaseOptions( 64 | apiKey: 'AIzaSyAMB1jzMjV-reKKlWSjo3NhC1mC6n1XTxM', 65 | appId: '1:504449834445:ios:f920537a3e69af86afb884', 66 | messagingSenderId: '504449834445', 67 | projectId: 'mvvm-template-apptex', 68 | storageBucket: 'mvvm-template-apptex.appspot.com', 69 | iosClientId: '504449834445-krdr51q5p2g13sdqn3qunj3irkc8o858.apps.googleusercontent.com', 70 | iosBundleId: 'com.example.mvvmTemplate', 71 | ); 72 | 73 | static const FirebaseOptions macos = FirebaseOptions( 74 | apiKey: 'AIzaSyAMB1jzMjV-reKKlWSjo3NhC1mC6n1XTxM', 75 | appId: '1:504449834445:ios:f920537a3e69af86afb884', 76 | messagingSenderId: '504449834445', 77 | projectId: 'mvvm-template-apptex', 78 | storageBucket: 'mvvm-template-apptex.appspot.com', 79 | iosClientId: '504449834445-krdr51q5p2g13sdqn3qunj3irkc8o858.apps.googleusercontent.com', 80 | iosBundleId: 'com.example.mvvmTemplate', 81 | ); 82 | } 83 | -------------------------------------------------------------------------------- /lib/locator.dart: -------------------------------------------------------------------------------- 1 | import 'package:get_it/get_it.dart'; 2 | import 'package:mvvm_template/core/config/config.dart'; 3 | import 'package:mvvm_template/core/enums/env.dart'; 4 | import 'package:mvvm_template/core/services/api_services.dart'; 5 | import 'package:mvvm_template/core/services/authentication/custom%20backend/auth_service.dart'; 6 | import 'package:mvvm_template/core/services/authentication/firebase/fire_auth.dart'; 7 | import 'package:mvvm_template/core/services/database/custom%20backend/database_service.dart'; 8 | import 'package:mvvm_template/core/services/database/firestore/firebase_db_service.dart'; 9 | import 'package:mvvm_template/core/services/file_picker_service.dart'; 10 | import 'package:mvvm_template/core/services/local_storage_service.dart'; 11 | import 'package:mvvm_template/core/services/location_service.dart'; 12 | import 'package:mvvm_template/core/services/notification_service.dart'; 13 | 14 | GetIt locator = GetIt.instance; 15 | 16 | setupLocator(Env env) async { 17 | //TODO comment the dependencies which are not required 18 | 19 | //The ordering of putting the dependencies matter here 20 | //For example if Auth service is using some function of 21 | //Database service then Database service needs to be put 22 | //before the Auth service. 23 | locator.registerSingleton(Config(env)); 24 | locator.registerSingleton(LocalStorageService()); 25 | locator.registerSingleton(NotificationsService()); 26 | locator.registerSingleton(ApiServices()); 27 | locator.registerLazySingleton(() => DatabaseService()); 28 | locator.registerLazySingleton(() => FirebaseService()); 29 | locator.registerSingleton(LocationService()); 30 | locator.registerSingleton(AuthService()); 31 | locator.registerSingleton(FireAuth()); 32 | locator.registerLazySingleton(() => FilePickerService()); 33 | } 34 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:firebase_core/firebase_core.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:mvvm_template/app.dart'; 4 | import 'package:mvvm_template/core/enums/env.dart'; 5 | import 'package:mvvm_template/core/others/logger_customization/custom_logger.dart'; 6 | import 'package:mvvm_template/firebase_options.dart'; 7 | import 'package:mvvm_template/locator.dart'; 8 | import 'package:flutter/services.dart'; 9 | 10 | Future main() async { 11 | final log = CustomLogger(className: 'main'); 12 | try { 13 | WidgetsFlutterBinding.ensureInitialized(); 14 | await Firebase.initializeApp( 15 | options: DefaultFirebaseOptions.currentPlatform, 16 | ); 17 | await setupLocator(Env.production); 18 | await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); 19 | runApp(const MyApp(title: 'App Name')); 20 | } catch (e) { 21 | log.e("$e"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/ui/custom_widgets/bottom_nav_bar/fab_bar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 | 4 | class FABBottomAppBarItem { 5 | FABBottomAppBarItem({this.icon, this.text}); 6 | Widget? icon; 7 | String? text; 8 | } 9 | 10 | class FABBottomAppBar extends StatefulWidget { 11 | FABBottomAppBar({ 12 | Key? key, 13 | required this.items, 14 | this.centerItemText, 15 | this.height = 70.0, 16 | this.iconSize = 30, 17 | this.backgroundColor, 18 | this.color, 19 | this.selectedColor, 20 | this.notchedShape, 21 | required this.onTabSelected, 22 | this.isNestedBottomBar = false, 23 | }) : super(key: key) { 24 | assert(items.length == 2 || items.length == 4); 25 | } 26 | final List items; 27 | final String? centerItemText; 28 | final double? height; 29 | final double? iconSize; 30 | final Color? backgroundColor; 31 | final Color? color; 32 | final Color? selectedColor; 33 | final NotchedShape? notchedShape; 34 | final ValueChanged onTabSelected; 35 | final bool? isNestedBottomBar; 36 | 37 | @override 38 | State createState() => FABBottomAppBarState(); 39 | } 40 | 41 | class FABBottomAppBarState extends State { 42 | int _selectedIndex = 0; 43 | 44 | _updateIndex(int index) { 45 | widget.onTabSelected(index); 46 | setState(() { 47 | _selectedIndex = index; 48 | }); 49 | } 50 | 51 | @override 52 | Widget build(BuildContext context) { 53 | List items = List.generate(widget.items.length, (int index) { 54 | return _buildTabItem( 55 | item: widget.items[index], 56 | index: index, 57 | onPressed: _updateIndex, 58 | ); 59 | }); 60 | items.insert(items.length >> 1, _buildMiddleTabItem()); 61 | 62 | return Container( 63 | padding: const EdgeInsets.only(bottom: 0), 64 | decoration: BoxDecoration( 65 | borderRadius: BorderRadius.circular(30), 66 | color: Colors.transparent, 67 | ), 68 | child: ClipRRect( 69 | borderRadius: BorderRadius.circular(30), 70 | child: BottomAppBar( 71 | elevation: 0.0, 72 | shape: widget.notchedShape, 73 | notchMargin: 4.0, 74 | color: widget.backgroundColor, 75 | child: Row( 76 | mainAxisSize: MainAxisSize.max, 77 | mainAxisAlignment: MainAxisAlignment.spaceAround, 78 | children: items, 79 | ), 80 | ), 81 | ), 82 | ); 83 | } 84 | 85 | Widget _buildMiddleTabItem() { 86 | return Expanded( 87 | child: SizedBox( 88 | height: widget.height, 89 | // height: 10, 90 | child: SizedBox(height: widget.iconSize), 91 | ), 92 | ); 93 | } 94 | 95 | Widget _buildTabItem({ 96 | FABBottomAppBarItem? item, 97 | int? index, 98 | ValueChanged? onPressed, 99 | }) { 100 | return Expanded( 101 | child: SizedBox( 102 | height: widget.height, 103 | child: Material( 104 | type: MaterialType.transparency, 105 | child: InkWell( 106 | onTap: widget.isNestedBottomBar! 107 | ? () { 108 | onPressed!(index!); 109 | setState(() { 110 | _selectedIndex = index; 111 | }); 112 | // Get.offAll(AppDrawer( 113 | // child: RootScreen(), 114 | // )); 115 | } 116 | : () => onPressed!(index!), 117 | child: Column( 118 | crossAxisAlignment: CrossAxisAlignment.center, 119 | mainAxisAlignment: MainAxisAlignment.center, 120 | children: [ 121 | item!.icon!, 122 | index == _selectedIndex 123 | ? Container( 124 | height: 7.h, 125 | ) 126 | : Container(), 127 | index == _selectedIndex 128 | ? Container( 129 | height: 6.r, 130 | width: 6.r, 131 | decoration: BoxDecoration( 132 | color: Colors.white, 133 | borderRadius: BorderRadius.circular(5.r), 134 | ), 135 | ) 136 | : Container(), 137 | ], 138 | ), 139 | ), 140 | ), 141 | ), 142 | ); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /lib/ui/custom_widgets/dialogs/auth_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class AuthDialog extends StatelessWidget { 4 | final String message; 5 | final String title; 6 | 7 | const AuthDialog({Key? key, required this.title, required this.message}) 8 | : super(key: key); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return AlertDialog( 13 | title: Text(title), 14 | content: Text(message), 15 | actions: [ 16 | ElevatedButton( 17 | onPressed: () { 18 | Navigator.pop(context); 19 | }, 20 | child: const Text('ok'), 21 | ), 22 | ], 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/ui/custom_widgets/dialogs/network_error_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class NetworkErrorDialog extends StatelessWidget { 4 | const NetworkErrorDialog({Key? key}) : super(key: key); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return const AlertDialog( 9 | title: Text('network_error_title'), 10 | content: Text('network_error_content'), 11 | ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/ui/custom_widgets/dialogs/request_failed_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class RequestFailedDialog extends StatelessWidget { 4 | final String errorMessage; 5 | 6 | const RequestFailedDialog({Key? key, required this.errorMessage}) 7 | : super(key: key); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return AlertDialog( 12 | title: const Text('requestFailedTitle'), 13 | content: Text(errorMessage), 14 | actions: [ 15 | ElevatedButton( 16 | onPressed: () { 17 | Navigator.pop(context); 18 | }, 19 | child: const Text('ok'), 20 | ), 21 | ], 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/ui/custom_widgets/dialogs/request_success_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class RequestSuccessDialog extends StatelessWidget { 4 | final String successMsg; 5 | 6 | const RequestSuccessDialog({Key? key, required this.successMsg}) 7 | : super(key: key); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return AlertDialog( 12 | title: const Text('requestSuccessTitle'), 13 | content: Text(successMsg), 14 | actions: [ 15 | ElevatedButton( 16 | onPressed: () { 17 | Navigator.pop(context); 18 | }, 19 | child: const Text('ok'), 20 | ), 21 | ], 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/ui/custom_widgets/gender_radio_group.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mvvm_template/ui/custom_widgets/single_radio_button.dart'; 3 | 4 | class GenderRadioGroup extends StatelessWidget { 5 | // ignore: prefer_typing_uninitialized_variables 6 | final model; 7 | 8 | const GenderRadioGroup(this.model, {Key? key}) : super(key: key); 9 | @override 10 | Widget build(BuildContext context) { 11 | return Row( 12 | children: [ 13 | const Text( 14 | "gender", 15 | // style: textStyleWithHacenFont.copyWith( 16 | // fontSize: ScreenUtil().setSp(12), color: Colors.white), 17 | ), 18 | const SizedBox(width: 40), 19 | // Radio( 20 | // value: 0, 21 | // activeColor: primaryColor, 22 | // groupValue: 23 | // model.selectedGenderIndex, 24 | // onChanged: (val) { 25 | // model.updateIndex(val); 26 | // }, 27 | // ), 28 | CustomSingleRadioButton( 29 | isSelected: model.selectedGenderIndex == 0, 30 | onPressed: () { 31 | model.updateIndex(0); 32 | }, 33 | ), 34 | const Text( 35 | "male", 36 | // style: textStyleWithHacenFont.copyWith( 37 | // fontSize: ScreenUtil().setSp(12), color: Colors.white), 38 | ), 39 | const SizedBox(width: 10), 40 | // Radio( 41 | // value: 1, 42 | // activeColor: primaryColor, 43 | // groupValue: model.selectedGenderIndex, 44 | // onChanged: (val) { 45 | // model.updateIndex(val); 46 | // }, 47 | // ), 48 | CustomSingleRadioButton( 49 | isSelected: model.selectedGenderIndex == 1, 50 | onPressed: () { 51 | debugPrint('Update Gender Index to 1'); 52 | model.updateIndex(1); 53 | }, 54 | ), 55 | const Text( 56 | "female", 57 | // style: textStyleWithHacenFont.copyWith( 58 | // fontSize: ScreenUtil().setSp(12), color: Colors.white), 59 | ), 60 | ], 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/ui/custom_widgets/image_container.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class ImageContainer extends StatelessWidget { 4 | final double? height; 5 | final double? width; 6 | final double radius; 7 | final String assets; 8 | final Color? color; 9 | 10 | /// This is for local Asset 11 | final String? url; 12 | 13 | /// This one is for Network Image, 14 | final BoxFit fit; 15 | // final 16 | 17 | const ImageContainer( 18 | {Key? key, 19 | this.height, 20 | this.width, 21 | this.assets = "assets/static_assets/user_icon.png", 22 | this.radius = 0, 23 | this.url, 24 | this.fit = BoxFit.cover, 25 | this.color = Colors.transparent}) 26 | : super(key: key); 27 | @override 28 | Widget build(BuildContext context) { 29 | return url == null 30 | ? Container( 31 | height: height, 32 | width: width, 33 | decoration: BoxDecoration( 34 | color: color, 35 | borderRadius: BorderRadius.circular(radius), 36 | image: DecorationImage( 37 | image: AssetImage(assets), 38 | fit: fit, 39 | )), 40 | ) 41 | : ClipRRect( 42 | borderRadius: BorderRadius.circular(radius), 43 | child: FadeInImage( 44 | width: width, 45 | height: height, 46 | image: NetworkImage(url!), 47 | placeholder: AssetImage(assets), 48 | fit: fit, 49 | ), 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lib/ui/custom_widgets/shimmer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 | import 'package:shimmer/shimmer.dart'; 4 | 5 | class ShimmersScreen extends StatelessWidget { 6 | /// itemCount: the amount of time the listview will generate the shimmer design by default it is 1. 7 | final int? itemCount; 8 | const ShimmersScreen({Key? key, this.itemCount}) : super(key: key); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Column( 13 | children: [ 14 | Shimmer.fromColors( 15 | baseColor: Colors.grey[300]!, 16 | highlightColor: Colors.grey[100]!, 17 | child: ListView.builder( 18 | itemCount: itemCount ?? 1, 19 | shrinkWrap: true, 20 | physics: const NeverScrollableScrollPhysics(), 21 | itemBuilder: (context, index) => shimmerDesign(), 22 | ), 23 | ) 24 | // shimmerDesign() 25 | ], 26 | ); 27 | } 28 | 29 | /// --------------- ------------------------------------------------------------ 30 | /// The design on shimmer is in the followin function 31 | /// If you want to change the design according to you need 32 | /// make changes in the following function 33 | /// ---------------------------------------------------------------------------- 34 | Column shimmerDesign() { 35 | return Column( 36 | children: [ 37 | Row( 38 | children: [ 39 | Container( 40 | margin: EdgeInsets.only(left: 6.w), 41 | height: 60.h, 42 | width: 60.w, 43 | decoration: BoxDecoration( 44 | shape: BoxShape.circle, 45 | color: Colors.grey[300], 46 | ), 47 | ), 48 | Column( 49 | crossAxisAlignment: CrossAxisAlignment.start, 50 | children: [ 51 | ShimmerContainer(width: 170.w), 52 | ShimmerContainer(width: 120.w), 53 | ShimmerContainer(width: 220.w), 54 | ], 55 | ) 56 | ], 57 | ), 58 | SizedBox(height: 10.h), 59 | ShimmerContainer( 60 | width: 1.sw, 61 | height: 250.h, 62 | isBorderCircular: false, 63 | ), 64 | Row( 65 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 66 | children: [ 67 | Row( 68 | children: [ 69 | SizedBox(width: 8.w), 70 | const ShimmerContainer(width: 15, horizontalPadding: 2), 71 | const ShimmerContainer(width: 20, horizontalPadding: 2), 72 | const ShimmerContainer(width: 25, horizontalPadding: 2), 73 | const ShimmerContainer(width: 55, horizontalPadding: 2), 74 | ], 75 | ), 76 | const ShimmerContainer(width: 100), 77 | ], 78 | ), 79 | SizedBox(height: 40.h), 80 | ], 81 | ); 82 | } 83 | } 84 | 85 | /// ------------------------------------------------------------------------------------------------ 86 | /// 87 | /// All of the design of ShimmerDesign function is made of single container 88 | /// ---- MAJOR PARAMETERS ---- 89 | /// 90 | /// -> double height: pass the desired height of the container 91 | /// -> double width: pass the desired width of the container 92 | /// -> double horizontalPadding: for the padding from left and right, default is 10 93 | /// -> double verticalPadding: for the padding from top and bottom, default is 2 94 | /// -> bool isBorderCircular: is true, the container will have circular border else not 95 | /// 96 | /// ------------------------------------------------------------------------------------------------ 97 | class ShimmerContainer extends StatelessWidget { 98 | final double? height, width, horizontalPadding, verticalPadding; 99 | final bool? isBorderCircular; 100 | const ShimmerContainer({ 101 | Key? key, 102 | this.height, 103 | this.width, 104 | this.horizontalPadding, 105 | this.verticalPadding, 106 | this.isBorderCircular, 107 | }) : super(key: key); 108 | 109 | @override 110 | Widget build(BuildContext context) { 111 | return Container( 112 | margin: EdgeInsets.symmetric( 113 | vertical: verticalPadding ?? 2, horizontal: horizontalPadding ?? 10), 114 | height: height ?? 15.h, 115 | width: width ?? 120.h, 116 | decoration: BoxDecoration( 117 | color: Colors.grey[300], 118 | borderRadius: isBorderCircular ?? true 119 | ? BorderRadius.circular(8) 120 | : BorderRadius.circular(0), 121 | ), 122 | ); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /lib/ui/custom_widgets/single_radio_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mvvm_template/core/theme/app_colors.dart'; 3 | 4 | class CustomSingleRadioButton extends StatelessWidget { 5 | final bool isSelected; 6 | // ignore: prefer_typing_uninitialized_variables 7 | final onPressed; 8 | const CustomSingleRadioButton( 9 | {Key? key, this.isSelected = false, this.onPressed}) 10 | : super(key: key); 11 | @override 12 | Widget build(BuildContext context) { 13 | return InkWell( 14 | onTap: onPressed, 15 | child: Padding( 16 | padding: const EdgeInsets.all(8.0), 17 | child: Container( 18 | height: 14, 19 | width: 14, 20 | padding: const EdgeInsets.all(2), 21 | decoration: BoxDecoration( 22 | borderRadius: BorderRadius.circular(50), 23 | color: Colors.white, 24 | ), 25 | child: Container( 26 | height: 10, 27 | width: 10, 28 | decoration: BoxDecoration( 29 | borderRadius: BorderRadius.circular(50), 30 | color: 31 | isSelected ? AppColors.primaryColor : Colors.transparent), 32 | ), 33 | ), 34 | ), 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/ui/screens/authentication/forget_password/forget_password_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mvvm_template/core/constants/my_utils.dart'; 3 | import 'package:mvvm_template/core/enums/view_state.dart'; 4 | import 'package:mvvm_template/core/others/base_view_model.dart'; 5 | import 'package:mvvm_template/core/services/authentication/firebase/fire_auth.dart'; 6 | import 'package:mvvm_template/core/services/navigation_service.dart'; 7 | import 'package:mvvm_template/locator.dart'; 8 | import 'package:mvvm_template/ui/custom_widgets/dialogs/auth_dialog.dart'; 9 | 10 | class ForgetPasswordScreenViewModel extends BaseViewModel { 11 | FireAuth authService = locator(); 12 | final NavigationService _navigationService = locator(); 13 | //ResetPasswordBody resetPasswordBody = ResetPasswordBody(); 14 | TextEditingController emailController = TextEditingController(); 15 | //late ResetPasswordResponse response; 16 | 17 | resetPassword() async { 18 | setState(ViewState.busy); 19 | bool emailSent = await authService.resetPassword(emailController.text); 20 | if (!emailSent) { 21 | MyUtils.myShowDialog( 22 | const AuthDialog( 23 | title: 'Error', message: 'Failed to send password reset email'), 24 | ); 25 | } 26 | setState(ViewState.idle); 27 | _navigationService.goBack(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/ui/screens/authentication/login_screen/login_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mvvm_template/core/enums/view_state.dart'; 3 | import 'package:mvvm_template/core/others/base_view_model.dart'; 4 | import 'package:mvvm_template/core/others/logger_customization/custom_logger.dart'; 5 | import 'package:mvvm_template/core/services/authentication/firebase/fire_auth.dart'; 6 | import 'package:mvvm_template/core/services/navigation_service.dart'; 7 | import 'package:mvvm_template/locator.dart'; 8 | 9 | class LoginViewModel extends BaseViewModel { 10 | final log = CustomLogger(className: 'LoginViewModel'); 11 | bool isRememberMe = false; 12 | FireAuth authService = FireAuth(); 13 | final NavigationService _navigationService = locator(); 14 | // LoginBody loginBody = LoginBody(); 15 | // late AuthResponse response; 16 | 17 | TextEditingController emailController = TextEditingController(); 18 | TextEditingController passwordController = TextEditingController(); 19 | final formKey = GlobalKey(); 20 | 21 | bool passwordVisibility = true; 22 | 23 | togglePasswordVisibility() { 24 | setState(ViewState.busy); 25 | passwordVisibility = !passwordVisibility; 26 | setState(ViewState.idle); 27 | } 28 | 29 | requestLogin() async { 30 | setState(ViewState.busy); 31 | try { 32 | await authService.signInWithEmailAndPassword( 33 | email: emailController.text, 34 | password: passwordController.text, 35 | ); 36 | } catch (e, s) { 37 | log.d("@LoginViewModel requestLogin Exceptions : $e"); 38 | log.d(s); 39 | } 40 | setState(ViewState.idle); 41 | } 42 | 43 | toggleIsRememberMe() { 44 | debugPrint('@toggleIsRememberMe: isRememberMe: $isRememberMe'); 45 | isRememberMe = !isRememberMe; 46 | notifyListeners(); 47 | } 48 | 49 | navigateTo(String routeName) { 50 | _navigationService.navigateTo(routeName); 51 | } 52 | 53 | @override 54 | void dispose() { 55 | emailController.dispose(); 56 | passwordController.dispose(); 57 | super.dispose(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/ui/screens/authentication/signup_screen/signup_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:firebase_auth/firebase_auth.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mvvm_template/core/Routes/routes.dart'; 6 | import 'package:mvvm_template/core/constants/my_utils.dart'; 7 | import 'package:mvvm_template/core/enums/view_state.dart'; 8 | import 'package:mvvm_template/core/models/user/profile.dart'; 9 | import 'package:mvvm_template/core/others/base_view_model.dart'; 10 | import 'package:mvvm_template/core/services/authentication/firebase/fire_auth.dart'; 11 | import 'package:mvvm_template/core/services/database/firestore/firebase_db_service.dart'; 12 | import 'package:mvvm_template/core/services/file_picker_service.dart'; 13 | import 'package:mvvm_template/core/services/navigation_service.dart'; 14 | import 'package:mvvm_template/locator.dart'; 15 | import 'package:mvvm_template/ui/custom_widgets/dialogs/auth_dialog.dart'; 16 | 17 | class SignUpViewModel extends BaseViewModel { 18 | final FireAuth _authService = locator(); 19 | final FirebaseService _dbService = locator(); 20 | final FilePickerService _imagePickerService = locator(); 21 | final NavigationService _navigationService = locator(); 22 | int? selectedGenderIndex; 23 | UserProfile userProfile = UserProfile(); 24 | File? image; 25 | //SignUpBody signUpBody = SignUpBody(); 26 | //late AuthResponse response; 27 | 28 | TextEditingController userNameController = TextEditingController(); 29 | TextEditingController emailController = TextEditingController(); 30 | TextEditingController passwordController = TextEditingController(); 31 | TextEditingController locationController = TextEditingController(); 32 | 33 | bool passwordVisibility = true; 34 | 35 | togglePasswordVisibility() { 36 | setState(ViewState.busy); 37 | passwordVisibility = !passwordVisibility; 38 | setState(ViewState.idle); 39 | } 40 | 41 | updateIndex(val) { 42 | selectedGenderIndex = val; 43 | notifyListeners(); 44 | } 45 | 46 | requestSignUp() async { 47 | setState(ViewState.busy); 48 | User? user = await _authService.createUserWithEmailAndPassword( 49 | email: emailController.text, 50 | password: passwordController.text, 51 | ); 52 | if (user == null) { 53 | MyUtils.myShowDialog( 54 | const AuthDialog( 55 | title: 'Error', message: 'Failed to create new account'), 56 | ); 57 | } else { 58 | userProfile.gender = selectedGenderIndex == 0 ? "Male" : "Female"; 59 | String uid = await _dbService.uploadUserData(userProfile); 60 | if (image != null) { 61 | String imgUrl = 62 | await _dbService.uploadFile(image!, 'Users/Profiles/$uid'); 63 | _dbService.updateUserInfo( 64 | uid, 65 | { 66 | 'imageUrl': imgUrl, 67 | }, 68 | ); 69 | } 70 | _navigationService.pushReplacementNamed(AppRoutes.navigationRoute); 71 | } 72 | setState(ViewState.idle); 73 | } 74 | 75 | pickImage() async { 76 | image = await _imagePickerService.pickImage(); 77 | notifyListeners(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/ui/screens/home_screen/home_screen.dart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/lib/ui/screens/home_screen/home_screen.dart -------------------------------------------------------------------------------- /lib/ui/screens/home_screen/home_screen_view_model.dart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/lib/ui/screens/home_screen/home_screen_view_model.dart -------------------------------------------------------------------------------- /lib/ui/screens/navigation/navigation_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mvvm_template/core/others/base_view_model.dart'; 3 | import 'package:mvvm_template/core/services/navigation_service.dart'; 4 | import 'package:mvvm_template/core/services/user_data_service.dart'; 5 | import 'package:mvvm_template/locator.dart'; 6 | 7 | class NavigationScreenViewModel extends BaseViewModel { 8 | NavigationScreenViewModel() { 9 | if (!locator.isRegistered()) { 10 | locator.registerSingleton( 11 | UserDataService(), 12 | dispose: (param) { 13 | param.dispose(); 14 | }, 15 | ); 16 | } 17 | initState(); 18 | } 19 | 20 | final NavigationService _navigationService = locator(); 21 | 22 | void initState() { 23 | final userDataService = locator(); 24 | userDataService.initUserData(); 25 | } 26 | 27 | List allScreen = [ 28 | // AppDrawer(child: DashboardScreen()), 29 | // MyCardScreen(), 30 | // CategoryScreen(enableBackButton: false), 31 | // ProfileScreen() 32 | ]; 33 | int selectedScreen = 0; 34 | 35 | bool isEnableBottomBar = true; 36 | 37 | updatedScreenIndex(int index) { 38 | selectedScreen = index; 39 | notifyListeners(); 40 | } 41 | 42 | updateBottomBarStatus(bool val) { 43 | isEnableBottomBar = val; 44 | notifyListeners(); 45 | } 46 | 47 | goBack(dynamic value) { 48 | _navigationService.pop(value); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /lib/ui/screens/onboarding/onboarding_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:logger/logger.dart'; 2 | import 'package:mvvm_template/core/models/other/onboarding.dart'; 3 | import 'package:mvvm_template/core/others/base_view_model.dart'; 4 | import 'package:mvvm_template/core/services/local_storage_service.dart'; 5 | import 'package:mvvm_template/locator.dart'; 6 | import 'package:carousel_slider/carousel_controller.dart'; 7 | 8 | class OnboardingViewModel extends BaseViewModel { 9 | final Logger log = Logger(); 10 | late int currentPageIndex; 11 | late List onboardingList; 12 | final _localStorageService = locator(); 13 | late CarouselController controller = CarouselController(); 14 | 15 | OnboardingViewModel(this.currentPageIndex, this.onboardingList); 16 | 17 | updatePage(index) { 18 | log.d('@updateOnboarding page with index: $index'); 19 | currentPageIndex = index; 20 | _localStorageService.onBoardingPageCount = index; 21 | notifyListeners(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/ui/screens/pin_location/pin_location_screen.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:google_maps_flutter/google_maps_flutter.dart'; 5 | import 'package:mvvm_template/core/enums/view_state.dart'; 6 | import 'package:mvvm_template/core/services/navigation_service.dart'; 7 | import 'package:mvvm_template/locator.dart'; 8 | import 'package:mvvm_template/ui/screens/pin_location/pin_location_view_model.dart'; 9 | import 'package:provider/provider.dart'; 10 | 11 | class PinLocationScreen extends StatelessWidget { 12 | final Completer _controller = Completer(); 13 | 14 | PinLocationScreen({Key? key}) : super(key: key); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return ChangeNotifierProvider( 19 | create: (context) => PinLocationViewModel(), 20 | child: Consumer(builder: (context, model, child) { 21 | return Scaffold( 22 | floatingActionButtonLocation: 23 | FloatingActionButtonLocation.centerFloat, 24 | floatingActionButton: FloatingActionButton( 25 | // backgroundColor: baseColor, 26 | onPressed: () { 27 | model.getAndAnimateToCurrentLocation(); 28 | }, 29 | child: const Icon(Icons.gps_fixed), 30 | ), 31 | appBar: AppBar( 32 | title: const Text('Active Location'), 33 | // actions: [ 34 | // Padding( 35 | // padding: const EdgeInsets.all(10.0), 36 | // child: Image.asset( 37 | // '$image/logo2.png', 38 | // height: 34.h, 39 | // width: 34.w, 40 | // ), 41 | // ) 42 | // ], 43 | ), 44 | body: model.state == ViewState.busy 45 | ? const Center(child: CircularProgressIndicator()) 46 | : Stack( 47 | children: [ 48 | GoogleMap( 49 | onTap: (location) { 50 | model.addMarker(location); 51 | }, 52 | mapType: MapType.normal, 53 | initialCameraPosition: model.initialCameraPosition, 54 | onMapCreated: (GoogleMapController controller) { 55 | model.controller = controller; 56 | _controller.complete(controller); 57 | }, 58 | markers: model.markers, 59 | ), 60 | if (model.selectedLocation != null) 61 | Align( 62 | alignment: Alignment.topCenter, 63 | child: Padding( 64 | padding: const EdgeInsets.only(top: 20), 65 | child: ElevatedButton( 66 | child: const Text('Confirm Location'), 67 | onPressed: () { 68 | locator() 69 | .pop(model.selectedLocation); 70 | }, 71 | ), 72 | ), 73 | ) 74 | else 75 | const Align( 76 | alignment: Alignment.topCenter, 77 | child: Padding( 78 | padding: EdgeInsets.only(top: 20), 79 | child: Card( 80 | child: Padding( 81 | padding: EdgeInsets.all(10), 82 | child: Text( 83 | 'Tap any location on Map to select the location.'), 84 | )), 85 | ), 86 | ), 87 | ], 88 | ), 89 | ); 90 | })); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /lib/ui/screens/pin_location/pin_location_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:google_maps_flutter/google_maps_flutter.dart'; 3 | import 'package:mvvm_template/core/enums/view_state.dart'; 4 | import 'package:mvvm_template/core/others/base_view_model.dart'; 5 | import 'package:mvvm_template/core/services/location_service.dart'; 6 | 7 | class PinLocationViewModel extends BaseViewModel { 8 | late GoogleMapController controller; 9 | late CameraPosition initialCameraPosition; 10 | // ignore: prefer_typing_uninitialized_variables 11 | var currentLocationIcon; 12 | Set markers = {}; 13 | late LatLng markerPosition; 14 | final _locationService = LocationService(); 15 | LatLng? currentLoc; 16 | LatLng? selectedLocation; 17 | 18 | PinLocationViewModel() { 19 | init(); 20 | } 21 | 22 | init() async { 23 | setState(ViewState.busy); 24 | markerPosition = const LatLng(34.045253, 71.593056); // Peshawar pin 25 | initialCameraPosition = CameraPosition(target: markerPosition, zoom: 10); 26 | _setupCustomMarkers(); 27 | setState(ViewState.idle); 28 | } 29 | 30 | _setupCustomMarkers() async { 31 | currentLocationIcon = await BitmapDescriptor.fromAssetImage( 32 | const ImageConfiguration(), 33 | 'assets/static_images/current-location.png'); 34 | } 35 | 36 | addMarker(LatLng markerLocation) { 37 | selectedLocation = markerLocation; 38 | markers.clear(); 39 | markers.add( 40 | Marker( 41 | position: markerLocation, 42 | markerId: const MarkerId('pin_location'), 43 | infoWindow: const InfoWindow(title: 'Your selected location'), 44 | ), 45 | ); 46 | notifyListeners(); 47 | } 48 | 49 | getAndAnimateToCurrentLocation() async { 50 | final loc = await _locationService.getCurrentLocation(); 51 | if (loc != null) { 52 | currentLoc = LatLng(loc.latitude, loc.longitude); 53 | markers.add(Marker( 54 | markerId: const MarkerId('current_location'), 55 | position: currentLoc!, 56 | infoWindow: const InfoWindow(title: 'Current Location'), 57 | icon: currentLocationIcon, 58 | )); 59 | notifyListeners(); 60 | controller.animateCamera(CameraUpdate.newCameraPosition( 61 | CameraPosition(target: currentLoc!, zoom: 10))); 62 | } 63 | } 64 | 65 | // launchUrl() async { 66 | // if (await canLaunch((_googleMapsUrl))) { 67 | // debugPrint('$_googleMapsUrl'); 68 | // await launch(_googleMapsUrl); 69 | // } else { 70 | // print('Exception @launchUrl: Can\'t launch $_googleMapsUrl'); 71 | // } 72 | // } 73 | } 74 | -------------------------------------------------------------------------------- /lib/ui/screens/splash_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:connectivity_plus/connectivity_plus.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:logger/logger.dart'; 4 | import 'package:mvvm_template/core/Routes/routes.dart'; 5 | import 'package:mvvm_template/core/constants/my_utils.dart'; 6 | import 'package:mvvm_template/core/models/other/onboarding.dart'; 7 | import 'package:mvvm_template/core/others/logger_customization/custom_logger.dart'; 8 | import 'package:mvvm_template/core/services/authentication/custom%20backend/auth_service.dart'; 9 | import 'package:mvvm_template/core/services/local_storage_service.dart'; 10 | import 'package:mvvm_template/core/services/navigation_service.dart'; 11 | import 'package:mvvm_template/locator.dart'; 12 | import 'package:mvvm_template/ui/custom_widgets/dialogs/network_error_dialog.dart'; 13 | 14 | class SplashScreen extends StatefulWidget { 15 | const SplashScreen({Key? key}) : super(key: key); 16 | 17 | @override 18 | State createState() => _SplashScreenState(); 19 | } 20 | 21 | class _SplashScreenState extends State { 22 | final _authService = locator(); 23 | final _localStorageService = locator(); 24 | // final _notificationService = locator(); 25 | final _navigationService = locator(); 26 | List onboardingList = []; 27 | final Logger log = CustomLogger(className: 'Splash Screen'); 28 | 29 | @override 30 | void didChangeDependencies() { 31 | _initialSetup(); 32 | super.didChangeDependencies(); 33 | } 34 | 35 | _initialSetup() async { 36 | await _localStorageService.init(); 37 | 38 | /// 39 | /// If not connected to internet, show an alert dialog 40 | /// to activate the network connection. 41 | /// 42 | final connectivityResult = await Connectivity().checkConnectivity(); 43 | if (connectivityResult == ConnectivityResult.none) { 44 | MyUtils.myShowDialog(const NetworkErrorDialog()); 45 | return; 46 | } 47 | 48 | // /// 49 | // ///initializing notification services 50 | // /// 51 | // await _notificationService.initConfigure(); 52 | 53 | /// 54 | /// Use the below [_getOnboardingData] method if the 55 | /// onboarding is dynamic (Means onboarding data coming from 56 | /// the apis) 57 | /// 58 | onboardingList = await _getOnboardingData(); 59 | 60 | /// 61 | /// Routing to the last onboarding screen user seen 62 | /// 63 | if (_localStorageService.onBoardingPageCount + 1 < onboardingList.length) { 64 | /// 65 | /// For better user experience we precache onboarding images in case 66 | /// they are coming from a remote server. 67 | /// Remove it if onboarding is static. 68 | /// 69 | final List preCachedImages = 70 | await _preCacheOnboardingImages(onboardingList); 71 | _navigationService.navigateTo( 72 | AppRoutes.onboardingRoute, 73 | arguments: ( 74 | onboardingList: onboardingList, 75 | preCachedImages: preCachedImages, 76 | currentIndex: _localStorageService.onBoardingPageCount 77 | ), 78 | ); 79 | return; 80 | } 81 | await _authService.doSetup(); 82 | 83 | /// 84 | ///checking if the user is login or not 85 | /// 86 | log.d('@_initialSetup. Login State: ${_authService.isLogin}'); 87 | if (_authService.isLogin) { 88 | _navigationService.navigateTo(AppRoutes.navigationRoute); 89 | } else { 90 | _navigationService.navigateTo(AppRoutes.loginRoute); 91 | } 92 | } 93 | 94 | Future> _preCacheOnboardingImages( 95 | List onboardingList) async { 96 | List preCachedImages = 97 | onboardingList.map((e) => Image.network(e.imgUrl!)).toList(); 98 | for (Image preCacheImg in preCachedImages) { 99 | await precacheImage(preCacheImg.image, context); 100 | } 101 | return preCachedImages; 102 | } 103 | 104 | // ignore: unused_element 105 | _getOnboardingData() async { 106 | ///uncomment below code 107 | // final response = await _dbService.getOnboardingData(); 108 | // if (response.success) { 109 | // return response.onboardingsList; 110 | // } else { 111 | // return []; 112 | // } 113 | List onboardings = []; 114 | return onboardings; 115 | } 116 | 117 | @override 118 | Widget build(BuildContext context) { 119 | /// 120 | /// Splash Screen UI goes here. 121 | /// 122 | return const Scaffold( 123 | body: Center(child: Text('Splash Screen')), 124 | ); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /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) awesome_notifications_registrar = 15 | fl_plugin_registry_get_registrar_for_plugin(registry, "AwesomeNotificationsPlugin"); 16 | awesome_notifications_plugin_register_with_registrar(awesome_notifications_registrar); 17 | g_autoptr(FlPluginRegistrar) modal_progress_hud_nsn_registrar = 18 | fl_plugin_registry_get_registrar_for_plugin(registry, "ModalProgressHudNsnPlugin"); 19 | modal_progress_hud_nsn_plugin_register_with_registrar(modal_progress_hud_nsn_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 | awesome_notifications 7 | modal_progress_hud_nsn 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.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "mvvm_template"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "mvvm_template"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import awesome_notifications 9 | import cloud_firestore 10 | import connectivity_plus 11 | import firebase_auth 12 | import firebase_core 13 | import firebase_crashlytics 14 | import firebase_messaging 15 | import firebase_storage 16 | import geolocator_apple 17 | import modal_progress_hud_nsn 18 | import path_provider_foundation 19 | import shared_preferences_foundation 20 | import url_launcher_macos 21 | 22 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 23 | AwesomeNotificationsPlugin.register(with: registry.registrar(forPlugin: "AwesomeNotificationsPlugin")) 24 | FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) 25 | ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) 26 | FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) 27 | FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) 28 | FLTFirebaseCrashlyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCrashlyticsPlugin")) 29 | FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin")) 30 | FLTFirebaseStoragePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseStoragePlugin")) 31 | GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) 32 | ModalProgressHudNsnPlugin.register(with: registry.registrar(forPlugin: "ModalProgressHudNsnPlugin")) 33 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 34 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 35 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 36 | } 37 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = mvvm_template 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.mvvmTemplate 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /macos/Runner/GoogleService-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CLIENT_ID 6 | 504449834445-krdr51q5p2g13sdqn3qunj3irkc8o858.apps.googleusercontent.com 7 | REVERSED_CLIENT_ID 8 | com.googleusercontent.apps.504449834445-krdr51q5p2g13sdqn3qunj3irkc8o858 9 | API_KEY 10 | AIzaSyAMB1jzMjV-reKKlWSjo3NhC1mC6n1XTxM 11 | GCM_SENDER_ID 12 | 504449834445 13 | PLIST_VERSION 14 | 1 15 | BUNDLE_ID 16 | com.example.mvvmTemplate 17 | PROJECT_ID 18 | mvvm-template-apptex 19 | STORAGE_BUCKET 20 | mvvm-template-apptex.appspot.com 21 | IS_ADS_ENABLED 22 | 23 | IS_ANALYTICS_ENABLED 24 | 25 | IS_APPINVITE_ENABLED 26 | 27 | IS_GCM_ENABLED 28 | 29 | IS_SIGNIN_ENABLED 30 | 31 | GOOGLE_APP_ID 32 | 1:504449834445:ios:f920537a3e69af86afb884 33 | 34 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/firebase_app_id_file.json: -------------------------------------------------------------------------------- 1 | { 2 | "file_generated_by": "FlutterFire CLI", 3 | "purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory", 4 | "GOOGLE_APP_ID": "1:504449834445:ios:f920537a3e69af86afb884", 5 | "FIREBASE_PROJECT_ID": "mvvm-template-apptex", 6 | "GCM_SENDER_ID": "504449834445" 7 | } -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: mvvm_template 2 | description: A new Flutter project. 3 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 4 | 5 | version: 1.0.0+1 6 | 7 | environment: 8 | sdk: '>=3.0.0 <4.0.0' 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | carousel_slider: ^4.0.0-nullsafety.0 15 | connectivity_plus: ^3.0.2 16 | device_info: ^2.0.3 17 | dio: ^4.0.6 18 | file_picker: ^5.2.5 19 | firebase_core: ^2.4.1 20 | firebase_messaging: ^14.2.1 21 | firebase_crashlytics: ^3.0.10 22 | firebase_performance: ^0.9.0+10 23 | flutter_advanced_drawer: ^1.3.2 24 | flutter_rating_bar: ^4.0.1 25 | flutter_screenutil: ^5.6.0 26 | flutter_staggered_grid_view: ^0.6.2 27 | flutter_svg: ^1.1.6 28 | geocoding: ^2.0.5 29 | geolocator: ^9.0.2 30 | get_it: ^7.2.0 31 | google_maps_flutter: ^2.2.3 32 | heic_to_jpg: ^0.2.0 33 | image_picker: ^0.8.6 34 | intl: ^0.18.0 35 | logger: ^1.1.0 36 | modal_progress_hud_nsn: ^0.3.0 37 | permission_handler: ^10.2.0 38 | provider: ^6.0.5 39 | shared_preferences: ^2.0.16 40 | shimmer: ^2.0.0 41 | url_launcher: ^6.1.7 42 | cupertino_icons: ^1.0.5 43 | firebase_messaging_platform_interface: ^4.2.10 44 | firebase_auth: ^4.2.5 45 | cloud_firestore: ^4.3.1 46 | firebase_storage: ^11.0.10 47 | path: ^1.8.2 48 | awesome_notifications: ^0.7.4+1 49 | path_provider: ^2.0.15 50 | image_cropper: ^4.0.1 51 | google_fonts: ^4.0.4 52 | control_style: ^0.0.3 53 | 54 | dev_dependencies: 55 | flutter_test: 56 | sdk: flutter 57 | 58 | flutter_lints: ^2.0.1 59 | rename: ^2.1.1 60 | 61 | flutter: 62 | 63 | uses-material-design: true 64 | 65 | # To add assets to your application, add an assets section, like this: 66 | # assets: 67 | # - images/a_dot_burr.jpeg 68 | # - images/a_dot_ham.jpeg 69 | 70 | # An image asset can refer to one or more resolution-specific "variants", see 71 | # https://flutter.dev/assets-and-images/#resolution-aware 72 | 73 | # For details regarding adding assets from package dependencies, see 74 | # https://flutter.dev/assets-and-images/#from-packages 75 | 76 | # To add custom fonts to your application, add a fonts section here, 77 | # in this "flutter" section. Each entry in this list should have a 78 | # "family" key with the font family name, and a "fonts" key with a 79 | # list giving the asset and other descriptors for the font. For 80 | # example: 81 | # fonts: 82 | # - family: Schyler 83 | # fonts: 84 | # - asset: fonts/Schyler-Regular.ttf 85 | # - asset: fonts/Schyler-Italic.ttf 86 | # style: italic 87 | # - family: Trajan Pro 88 | # fonts: 89 | # - asset: fonts/TrajanPro.ttf 90 | # - asset: fonts/TrajanPro_Bold.ttf 91 | # weight: 700 92 | # 93 | # For details regarding fonts from package dependencies, 94 | # see https://flutter.dev/custom-fonts/#from-packages 95 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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 | mvvm_template 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mvvm_template", 3 | "short_name": "mvvm_template", 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/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(mvvm_template LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "mvvm_template") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 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 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /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 | 17 | void RegisterPlugins(flutter::PluginRegistry* registry) { 18 | AwesomeNotificationsPluginCApiRegisterWithRegistrar( 19 | registry->GetRegistrarForPlugin("AwesomeNotificationsPluginCApi")); 20 | ConnectivityPlusWindowsPluginRegisterWithRegistrar( 21 | registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); 22 | FirebaseCorePluginCApiRegisterWithRegistrar( 23 | registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); 24 | GeolocatorWindowsRegisterWithRegistrar( 25 | registry->GetRegistrarForPlugin("GeolocatorWindows")); 26 | ModalProgressHudNsnPluginRegisterWithRegistrar( 27 | registry->GetRegistrarForPlugin("ModalProgressHudNsnPlugin")); 28 | PermissionHandlerWindowsPluginRegisterWithRegistrar( 29 | registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); 30 | UrlLauncherWindowsRegisterWithRegistrar( 31 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 32 | } 33 | -------------------------------------------------------------------------------- /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 | awesome_notifications 7 | connectivity_plus 8 | firebase_core 9 | geolocator_windows 10 | modal_progress_hud_nsn 11 | permission_handler_windows 12 | url_launcher_windows 13 | ) 14 | 15 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 16 | ) 17 | 18 | set(PLUGIN_BUNDLED_LIBRARIES) 19 | 20 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 22 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 25 | endforeach(plugin) 26 | 27 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 28 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 29 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 30 | endforeach(ffi_plugin) 31 | -------------------------------------------------------------------------------- /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_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 37 | 38 | # Run the Flutter tool portions of the build. This must not be removed. 39 | add_dependencies(${BINARY_NAME} flutter_assemble) 40 | -------------------------------------------------------------------------------- /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.example" "\0" 93 | VALUE "FileDescription", "mvvm_template" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "mvvm_template" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "mvvm_template.exe" "\0" 98 | VALUE "ProductName", "mvvm_template" "\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 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /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.CreateAndShow(L"mvvm_template", 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/ShahSomething/mvvm-templete/68d28a8453ecfe7d4bb9e6ae81741eb57709e8dd/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 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /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 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | --------------------------------------------------------------------------------