├── .gitignore ├── .gitmodules ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── iotecksolutions │ │ │ │ └── todoapp │ │ │ │ └── MainActivity.java │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── iotecksolutions │ │ │ │ └── flutterboilerplate │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ ├── ic_appicon.png │ │ │ └── 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 ├── art ├── architecture.png └── flow.png ├── assets ├── fonts │ ├── Product-Sans-Bold-Italic.ttf │ ├── Product-Sans-Bold.ttf │ ├── Product-Sans-Italic.ttf │ └── Product-Sans-Regular.ttf ├── icons │ ├── ic_appicon.png │ └── ic_launcher.png ├── images │ ├── img_login.jpg │ └── img_no_jobs.png └── lang │ ├── da.json │ ├── en.json │ └── es.json ├── 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 │ ├── Info.plist │ └── Runner-Bridging-Header.h └── RunnerTests │ └── RunnerTests.swift ├── lib ├── constants │ ├── app_theme.dart │ ├── assets.dart │ ├── colors.dart │ ├── dimens.dart │ ├── font_family.dart │ └── strings.dart ├── core │ ├── data │ │ ├── local │ │ │ ├── encryption │ │ │ │ └── xxtea.dart │ │ │ └── sembast │ │ │ │ └── sembast_client.dart │ │ ├── network │ │ │ ├── constants │ │ │ │ └── network_constants.dart │ │ │ └── dio │ │ │ │ ├── configs │ │ │ │ └── dio_configs.dart │ │ │ │ ├── dio_client.dart │ │ │ │ └── interceptors │ │ │ │ ├── auth_interceptor.dart │ │ │ │ ├── logging_interceptor.dart │ │ │ │ └── retry_interceptor.dart │ │ └── sharedpref │ │ │ └── base_shared_preference_helper.dart │ ├── domain │ │ ├── model │ │ │ └── screen_args.dart │ │ └── usecase │ │ │ └── use_case.dart │ ├── extensions │ │ └── cap_extension.dart │ ├── stores │ │ ├── error │ │ │ ├── error_store.dart │ │ │ └── error_store.g.dart │ │ └── form │ │ │ ├── form_store.dart │ │ │ └── form_store.g.dart │ └── widgets │ │ ├── app_icon_widget.dart │ │ ├── empty_app_bar_widget.dart │ │ ├── progress_indicator_widget.dart │ │ ├── rounded_button_widget.dart │ │ └── textfield_widget.dart ├── data │ ├── di │ │ ├── data_layer_injection.dart │ │ └── module │ │ │ ├── local_module.dart │ │ │ ├── network_module.dart │ │ │ └── repository_module.dart │ ├── local │ │ ├── constants │ │ │ └── db_constants.dart │ │ └── datasources │ │ │ └── post │ │ │ └── post_datasource.dart │ ├── network │ │ ├── apis │ │ │ └── posts │ │ │ │ └── post_api.dart │ │ ├── constants │ │ │ └── endpoints.dart │ │ ├── dio_client.dart │ │ ├── exceptions │ │ │ └── network_exceptions.dart │ │ ├── interceptors │ │ │ └── error_interceptor.dart │ │ └── rest_client.dart │ ├── repository │ │ ├── post │ │ │ └── post_repository_impl.dart │ │ ├── setting │ │ │ └── setting_repository_impl.dart │ │ └── user │ │ │ └── user_repository_impl.dart │ └── sharedpref │ │ ├── constants │ │ └── preferences.dart │ │ └── shared_preference_helper.dart ├── di │ └── service_locator.dart ├── domain │ ├── di │ │ ├── domain_layer_injection.dart │ │ └── module │ │ │ └── usecase_module.dart │ ├── entity │ │ ├── language │ │ │ └── Language.dart │ │ ├── post │ │ │ ├── post.dart │ │ │ └── post_list.dart │ │ └── user │ │ │ └── user.dart │ ├── repository │ │ ├── post │ │ │ └── post_repository.dart │ │ ├── setting │ │ │ └── setting_repository.dart │ │ └── user │ │ │ └── user_repository.dart │ └── usecase │ │ ├── post │ │ ├── delete_post_usecase.dart │ │ ├── find_post_by_id_usecase.dart │ │ ├── get_post_usecase.dart │ │ ├── insert_post_usecase.dart │ │ └── udpate_post_usecase.dart │ │ └── user │ │ ├── is_logged_in_usecase.dart │ │ ├── login_usecase.dart │ │ ├── login_usecase.g.dart │ │ └── save_login_in_status_usecase.dart ├── main.dart ├── presentation │ ├── di │ │ ├── module │ │ │ └── store_module.dart │ │ └── presentation_layer_injection.dart │ ├── home │ │ ├── home.dart │ │ └── store │ │ │ ├── language │ │ │ ├── language_store.dart │ │ │ └── language_store.g.dart │ │ │ └── theme │ │ │ ├── theme_store.dart │ │ │ └── theme_store.g.dart │ ├── login │ │ ├── login.dart │ │ └── store │ │ │ ├── login_store.dart │ │ │ └── login_store.g.dart │ ├── my_app.dart │ └── post │ │ ├── post_list.dart │ │ └── store │ │ ├── post_store.dart │ │ └── post_store.g.dart └── utils │ ├── device │ └── device_utils.dart │ ├── dio │ ├── dio_error_util.dart │ └── dio_retry_interceptor.dart │ ├── locale │ └── app_localization.dart │ └── routes │ └── routes.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 │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements └── RunnerTests │ └── RunnerTests.swift ├── pubspec.yaml ├── test └── widget_test.dart ├── 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 | *.lock 4 | *.log 5 | *.pyc 6 | *.swp 7 | .DS_Store 8 | .atom/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # Visual Studio Code related 20 | .vscode/ 21 | 22 | # Flutter/Dart/Pub related 23 | **/doc/api/ 24 | .dart_tool/ 25 | .flutter-plugins 26 | .packages 27 | .pub-cache/ 28 | .pub/ 29 | build/ 30 | 31 | # Android related 32 | **/android/**/gradle-wrapper.jar 33 | **/android/.gradle 34 | **/android/captures/ 35 | **/android/gradlew 36 | **/android/gradlew.bat 37 | **/android/local.properties 38 | **/android/**/GeneratedPluginRegistrant.java 39 | 40 | # iOS/XCode related 41 | **/ios/**/*.mode1v3 42 | **/ios/**/*.mode2v3 43 | **/ios/**/*.moved-aside 44 | **/ios/**/*.pbxuser 45 | **/ios/**/*.perspectivev3 46 | **/ios/**/*sync/ 47 | **/ios/**/.sconsign.dblite 48 | **/ios/**/.tags* 49 | **/ios/**/.vagrant/ 50 | **/ios/**/DerivedData/ 51 | **/ios/**/Icon? 52 | **/ios/**/Pods/ 53 | **/ios/**/.symlinks/ 54 | **/ios/**/profile 55 | **/ios/**/xcuserdata 56 | **/ios/.generated/ 57 | **/ios/Flutter/App.framework 58 | **/ios/Flutter/Flutter.framework 59 | **/ios/Flutter/Generated.xcconfig 60 | **/ios/Flutter/app.flx 61 | **/ios/Flutter/app.zip 62 | **/ios/Flutter/flutter_assets/ 63 | **/ios/ServiceDefinitions.json 64 | **/ios/Runner/GeneratedPluginRegistrant.* 65 | 66 | # Exceptions to above rules. 67 | !**/ios/**/default.mode1v3 68 | !**/ios/**/default.mode2v3 69 | !**/ios/**/default.pbxuser 70 | !**/ios/**/default.perspectivev3 71 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 72 | .flutter-plugins-dependencies 73 | ios/Flutter/flutter_export_environment.sh 74 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "injection/inject.dart"] 2 | path = injection/inject.dart 3 | url = https://github.com/google/inject.dart 4 | -------------------------------------------------------------------------------- /.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: f468f3366c26a5092eb964a230ce7892fda8f2f8 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: f468f3366c26a5092eb964a230ce7892fda8f2f8 17 | base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 18 | - platform: android 19 | create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 20 | base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 21 | - platform: ios 22 | create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 23 | base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 24 | - platform: linux 25 | create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 26 | base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 27 | - platform: macos 28 | create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 29 | base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 30 | - platform: web 31 | create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 32 | base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 33 | - platform: windows 34 | create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 35 | base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 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 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## June 11, 2019 2 | 3 | * Added dependency injection 4 | * Refactored dio client 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Zubair Rehman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /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 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | id "dev.flutter.flutter-gradle-plugin" 5 | } 6 | 7 | def localProperties = new Properties() 8 | def localPropertiesFile = rootProject.file('local.properties') 9 | if (localPropertiesFile.exists()) { 10 | localPropertiesFile.withReader('UTF-8') { reader -> 11 | localProperties.load(reader) 12 | } 13 | } 14 | 15 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 16 | if (flutterVersionCode == null) { 17 | flutterVersionCode = '1' 18 | } 19 | 20 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 21 | if (flutterVersionName == null) { 22 | flutterVersionName = '1.0' 23 | } 24 | 25 | android { 26 | compileSdkVersion 34 27 | 28 | lintOptions { 29 | disable 'InvalidPackage' 30 | } 31 | 32 | defaultConfig { 33 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 34 | applicationId "com.iotecksolutions.todoapp" 35 | minSdkVersion flutter.minSdkVersion 36 | targetSdkVersion 34 37 | versionCode flutterVersionCode.toInteger() 38 | versionName flutterVersionName 39 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 40 | } 41 | 42 | buildTypes { 43 | release { 44 | // TODO: Add your own signing config for the release build. 45 | // Signing with the debug keys for now, so `flutter run --release` works. 46 | signingConfig signingConfigs.debug 47 | } 48 | } 49 | } 50 | 51 | flutter { 52 | source '../..' 53 | } 54 | 55 | dependencies { 56 | testImplementation 'junit:junit:4.12' 57 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 58 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 59 | } -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 15 | 19 | 27 | 31 | 32 | 33 | 36 | 37 | 38 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/iotecksolutions/todoapp/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.iotecksolutions.todoapp; 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | public class MainActivity extends FlutterActivity { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/iotecksolutions/flutterboilerplate/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.iotecksolutions.flutter_boilerplate_project 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/ic_appicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/android/app/src/main/res/drawable/ic_appicon.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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 | 8 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | rootProject.buildDir = '../build' 9 | subprojects { 10 | project.buildDir = "${rootProject.buildDir}/${project.name}" 11 | } 12 | subprojects { 13 | project.evaluationDependsOn(':app') 14 | } 15 | 16 | tasks.register("clean", Delete) { 17 | delete rootProject.buildDir 18 | } 19 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | android.enableJetifier=true 2 | android.useAndroidX=true 3 | org.gradle.jvmargs=-Xmx1536M 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version "7.3.0" apply false 22 | id "org.jetbrains.kotlin.android" version "1.7.10" apply false 23 | } 24 | 25 | include ":app" -------------------------------------------------------------------------------- /art/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/art/architecture.png -------------------------------------------------------------------------------- /art/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/art/flow.png -------------------------------------------------------------------------------- /assets/fonts/Product-Sans-Bold-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/assets/fonts/Product-Sans-Bold-Italic.ttf -------------------------------------------------------------------------------- /assets/fonts/Product-Sans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/assets/fonts/Product-Sans-Bold.ttf -------------------------------------------------------------------------------- /assets/fonts/Product-Sans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/assets/fonts/Product-Sans-Italic.ttf -------------------------------------------------------------------------------- /assets/fonts/Product-Sans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/assets/fonts/Product-Sans-Regular.ttf -------------------------------------------------------------------------------- /assets/icons/ic_appicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/assets/icons/ic_appicon.png -------------------------------------------------------------------------------- /assets/icons/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/assets/icons/ic_launcher.png -------------------------------------------------------------------------------- /assets/images/img_login.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/assets/images/img_login.jpg -------------------------------------------------------------------------------- /assets/images/img_no_jobs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/assets/images/img_no_jobs.png -------------------------------------------------------------------------------- /assets/lang/da.json: -------------------------------------------------------------------------------- 1 | { 2 | "login_start": "Below are list of strings for login da ", 3 | "login_et_user_email": "Brugernavn", 4 | "login_et_user_password": "Adgangskode", 5 | "login_btn_forgot_password": "Glemt adgangskode?", 6 | "login_btn_sign_in": "Log ind", 7 | "login_error_fill_fields": "Udfyld venligst alle felterne", 8 | "login_end": "------------------------------------------------------------------------------------", 9 | 10 | "home_start": "Below are list of strings for home", 11 | "home_tv_posts": "Indlæg", 12 | "home_tv_error": "Fejl", 13 | "home_tv_no_post_found": "Ingen indlæg fundet", 14 | "home_tv_choose_language": "Vælg sprog", 15 | "home_end": "-------------------------------------------------------------------------------------" 16 | 17 | } 18 | -------------------------------------------------------------------------------- /assets/lang/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "login_start": "Below are list of strings for login", 3 | "login_et_user_email": "Enter user email", 4 | "login_et_user_password": "Enter password", 5 | "login_btn_forgot_password": "Forgot Password?", 6 | "login_btn_sign_in": "Sign In", 7 | "login_error_fill_fields": "Please fill in all fields", 8 | "login_end": "------------------------------------------------------------------------------------", 9 | 10 | "home_start": "Below are list of strings for home", 11 | "home_tv_posts": "Posts", 12 | "home_tv_error": "Error", 13 | "home_tv_no_post_found": "No posts found", 14 | "home_tv_choose_language": "Choose Language", 15 | "home_end": "-------------------------------------------------------------------------------------" 16 | 17 | } 18 | -------------------------------------------------------------------------------- /assets/lang/es.json: -------------------------------------------------------------------------------- 1 | { 2 | "login_start": "Below are list of strings for login es ", 3 | "login_et_user_email": "Ingrese el correo electrónico del usuario", 4 | "login_et_user_password": "Introducir la contraseña", 5 | "login_btn_forgot_password": "¿Se te olvidó tu contraseña", 6 | "login_btn_sign_in": "Registrarse", 7 | "login_error_fill_fields": "Por favor complete todos los campos e", 8 | "login_end": "------------------------------------------------------------------------------------", 9 | 10 | "home_start": "Below are list of strings for home", 11 | "home_tv_posts": "Publicaciones", 12 | "home_tv_error": "Error", 13 | "home_tv_no_post_found": "No se han encontrado publicaciones", 14 | "home_tv_choose_language": "Elige lengua", 15 | "home_end": "-------------------------------------------------------------------------------------" 16 | } 17 | -------------------------------------------------------------------------------- /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 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /ios/Runner.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 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Flutter Boilerplate Project 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_boilerplate_project 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/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /lib/constants/assets.dart: -------------------------------------------------------------------------------- 1 | class Assets { 2 | Assets._(); 3 | 4 | // splash screen assets 5 | static const String appLogo = "assets/icons/ic_appicon.png"; 6 | 7 | // login screen assets 8 | static const String carBackground = "assets/images/img_login.jpg"; 9 | 10 | } -------------------------------------------------------------------------------- /lib/constants/colors.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class AppColors { 4 | AppColors._(); // this basically makes it so you can't instantiate this class 5 | 6 | static const Map orange = const { 7 | 50: const Color(0xFFFCF2E7), 8 | 100: const Color(0xFFF8DEC3), 9 | 200: const Color(0xFFF3C89C), 10 | 300: const Color(0xFFEEB274), 11 | 400: const Color(0xFFEAA256), 12 | 500: const Color(0xFFE69138), 13 | 600: const Color(0xFFE38932), 14 | 700: const Color(0xFFDF7E2B), 15 | 800: const Color(0xFFDB7424), 16 | 900: const Color(0xFFD56217) 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /lib/constants/dimens.dart: -------------------------------------------------------------------------------- 1 | class Dimens { 2 | Dimens._(); 3 | 4 | //for all screens 5 | static const double horizontal_padding = 12.0; 6 | static const double vertical_padding = 12.0; 7 | } -------------------------------------------------------------------------------- /lib/constants/font_family.dart: -------------------------------------------------------------------------------- 1 | class FontFamily { 2 | FontFamily._(); 3 | 4 | static String productSans = "ProductSans"; 5 | static String roboto = "Roboto"; 6 | } -------------------------------------------------------------------------------- /lib/constants/strings.dart: -------------------------------------------------------------------------------- 1 | class Strings { 2 | Strings._(); 3 | 4 | //General 5 | static const String appName = "Boilerplate Project"; 6 | } 7 | -------------------------------------------------------------------------------- /lib/core/data/local/encryption/xxtea.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:sembast/sembast.dart'; 4 | import 'package:xxtea/xxtea.dart'; 5 | 6 | class _XXTeaEncoder extends Converter, String> { 7 | final String key; 8 | 9 | _XXTeaEncoder(this.key); 10 | 11 | @override 12 | String convert(Map input) => 13 | xxtea.encryptToString(json.encode(input), key)!; 14 | } 15 | 16 | class _XXTeaDecoder extends Converter> { 17 | final String key; 18 | 19 | _XXTeaDecoder(this.key); 20 | 21 | @override 22 | Map convert(String input) { 23 | var result = json.decode(xxtea.decryptToString(input, key)!); 24 | if (result is Map) { 25 | return result.cast(); 26 | } 27 | throw FormatException('invalid input $input'); 28 | } 29 | } 30 | 31 | /// Simple encryption codec using xxtea 32 | /// It requires a password to encrypt/decrypt the data 33 | class _XXTeaCodec extends Codec, String> { 34 | late _XXTeaEncoder _encoder; 35 | late _XXTeaDecoder _decoder; 36 | 37 | /// A non null [password] to use for the encryption/decryption 38 | _XXTeaCodec(String password) { 39 | _encoder = _XXTeaEncoder(password); 40 | _decoder = _XXTeaDecoder(password); 41 | } 42 | 43 | @override 44 | Converter> get decoder => _decoder; 45 | 46 | @override 47 | Converter, String> get encoder => _encoder; 48 | } 49 | 50 | /// Create a codec to use when opening an encrypted sembast database 51 | /// 52 | /// The usage is then 53 | /// 54 | /// ```dart 55 | /// // Initialize the encryption codec with a user password 56 | /// var codec = getXXTeaCodec(password: '[your_user_password]'); 57 | /// // Open the database with the codec 58 | /// Database db = await factory.openDatabase(dbPath, codec: codec); 59 | /// 60 | /// // ...your database is ready to use as encrypted 61 | /// ``` 62 | SembastCodec getXXTeaCodec({required String password}) => 63 | SembastCodec(signature: 'xxtea', codec: _XXTeaCodec(password)); 64 | -------------------------------------------------------------------------------- /lib/core/data/local/sembast/sembast_client.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/data/local/encryption/xxtea.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:path/path.dart'; 4 | import 'package:sembast/sembast.dart'; 5 | import 'package:sembast/sembast_io.dart'; 6 | import 'package:sembast_web/sembast_web.dart'; 7 | 8 | class SembastClient { 9 | final Database _database; 10 | 11 | SembastClient(this._database); 12 | 13 | Database get database => _database; 14 | 15 | static Future provideDatabase({ 16 | String encryptionKey = '', 17 | required String databaseName, 18 | required String databasePath, 19 | }) async { 20 | // Path with the form: /platform-specific-directory/demo.db 21 | final dbPath = join(databasePath, databaseName); 22 | 23 | // Check to see if encryption is set, then provide codec 24 | // else init normal db with path 25 | // Database database; 26 | final database; 27 | if (encryptionKey.isNotEmpty) { 28 | var codec = getXXTeaCodec(password: encryptionKey); 29 | 30 | // Initialize the encryption codec with a user password 31 | if(kIsWeb) { 32 | var factory = databaseFactoryWeb; 33 | database = await factory.openDatabase(databaseName, codec: codec); 34 | } else { 35 | database = await databaseFactoryIo.openDatabase(dbPath, codec: codec); 36 | } 37 | } else { 38 | if(kIsWeb) { 39 | var factory = databaseFactoryWeb; 40 | database = await factory.openDatabase(databaseName); 41 | } else { 42 | database = await databaseFactoryIo.openDatabase(dbPath); 43 | } 44 | } 45 | 46 | // Return database instance 47 | return SembastClient(database); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/core/data/network/constants/network_constants.dart: -------------------------------------------------------------------------------- 1 | class NetworkConstants { 2 | NetworkConstants._(); 3 | 4 | // base url 5 | static const String baseUrl = 'http://jsonplaceholder.typicode.com'; 6 | 7 | // receiveTimeout 8 | static const int receiveTimeout = 15000; 9 | 10 | // connectTimeout 11 | static const int connectionTimeout = 30000; 12 | } -------------------------------------------------------------------------------- /lib/core/data/network/dio/configs/dio_configs.dart: -------------------------------------------------------------------------------- 1 | const _kDefaultReceiveTimeout = 10000; 2 | const _kDefaultConnectionTimeout = 10000; 3 | 4 | class DioConfigs { 5 | final String baseUrl; 6 | final int receiveTimeout; 7 | final int connectionTimeout; 8 | 9 | const DioConfigs({ 10 | required this.baseUrl, 11 | this.receiveTimeout = _kDefaultReceiveTimeout, 12 | this.connectionTimeout = _kDefaultConnectionTimeout, 13 | }); 14 | } 15 | -------------------------------------------------------------------------------- /lib/core/data/network/dio/dio_client.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | import 'configs/dio_configs.dart'; 4 | 5 | class DioClient { 6 | final DioConfigs dioConfigs; 7 | final Dio _dio; 8 | 9 | DioClient({required this.dioConfigs}) 10 | : _dio = Dio() 11 | ..options.baseUrl = dioConfigs.baseUrl 12 | ..options.connectTimeout = Duration(milliseconds: dioConfigs.connectionTimeout) 13 | ..options.receiveTimeout = Duration(milliseconds: dioConfigs.receiveTimeout); 14 | 15 | Dio get dio => _dio; 16 | 17 | Dio addInterceptors(Iterable interceptors) { 18 | return _dio..interceptors.addAll(interceptors); 19 | } 20 | } -------------------------------------------------------------------------------- /lib/core/data/network/dio/interceptors/auth_interceptor.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | 4 | class AuthInterceptor extends Interceptor { 5 | final AsyncValueGetter accessToken; 6 | 7 | AuthInterceptor({ 8 | required this.accessToken, 9 | }); 10 | 11 | @override 12 | Future onRequest( 13 | RequestOptions options, 14 | RequestInterceptorHandler handler, 15 | ) async { 16 | final String token = await accessToken() ?? ''; 17 | if (token.isNotEmpty) { 18 | options.headers.putIfAbsent('Authorization', () => 'Bearer $token'); 19 | } 20 | 21 | super.onRequest(options, handler); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/core/data/sharedpref/base_shared_preference_helper.dart: -------------------------------------------------------------------------------- 1 | mixin BaseSharedPreferenceHelper { 2 | Future clearSharedPreference(); 3 | } -------------------------------------------------------------------------------- /lib/core/domain/model/screen_args.dart: -------------------------------------------------------------------------------- 1 | // You can pass any object to the arguments parameter. 2 | // In this example, create a class that contains a customizable 3 | // key and value. 4 | class ScreenArguments { 5 | final String? key; 6 | final T? value; 7 | 8 | ScreenArguments({this.key, this.value}); 9 | } 10 | 11 | class ScreenArgumentKeys { 12 | ScreenArgumentKeys._(); 13 | 14 | static const String bookingId = 'booking_id'; 15 | } 16 | -------------------------------------------------------------------------------- /lib/core/domain/usecase/use_case.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | abstract class UseCase { 4 | FutureOr call({ required P params}); 5 | } -------------------------------------------------------------------------------- /lib/core/extensions/cap_extension.dart: -------------------------------------------------------------------------------- 1 | extension CapExtension on String { 2 | String get inCaps => '${this[0].toUpperCase()}${this.substring(1)}'; 3 | String get allInCaps => this.toUpperCase(); 4 | String toTitleCase() => replaceAll(RegExp(' +'), ' ').split(' ').map((str) => str.inCaps).join(' '); 5 | } -------------------------------------------------------------------------------- /lib/core/stores/error/error_store.dart: -------------------------------------------------------------------------------- 1 | import 'package:mobx/mobx.dart'; 2 | 3 | part 'error_store.g.dart'; 4 | 5 | class ErrorStore = _ErrorStore with _$ErrorStore; 6 | 7 | abstract class _ErrorStore with Store { 8 | 9 | // disposers 10 | late List _disposers; 11 | 12 | // constructor:--------------------------------------------------------------- 13 | _ErrorStore() { 14 | _disposers = [ 15 | reaction((_) => errorMessage, reset, delay: 200), 16 | ]; 17 | } 18 | 19 | // store variables:----------------------------------------------------------- 20 | @observable 21 | String errorMessage = ''; 22 | 23 | 24 | // actions:------------------------------------------------------------------- 25 | @action 26 | void setErrorMessage(String message) { 27 | this.errorMessage = message; 28 | } 29 | 30 | @action 31 | void reset(String value) { 32 | errorMessage = ''; 33 | } 34 | 35 | // dispose:------------------------------------------------------------------- 36 | @action 37 | dispose() { 38 | for (final disposer in _disposers) { 39 | disposer(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /lib/core/stores/error/error_store.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'error_store.dart'; 4 | 5 | // ************************************************************************** 6 | // StoreGenerator 7 | // ************************************************************************** 8 | 9 | // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic, no_leading_underscores_for_local_identifiers 10 | 11 | mixin _$ErrorStore on _ErrorStore, Store { 12 | late final _$errorMessageAtom = 13 | Atom(name: '_ErrorStore.errorMessage', context: context); 14 | 15 | @override 16 | String get errorMessage { 17 | _$errorMessageAtom.reportRead(); 18 | return super.errorMessage; 19 | } 20 | 21 | @override 22 | set errorMessage(String value) { 23 | _$errorMessageAtom.reportWrite(value, super.errorMessage, () { 24 | super.errorMessage = value; 25 | }); 26 | } 27 | 28 | late final _$_ErrorStoreActionController = 29 | ActionController(name: '_ErrorStore', context: context); 30 | 31 | @override 32 | void setErrorMessage(String message) { 33 | final _$actionInfo = _$_ErrorStoreActionController.startAction( 34 | name: '_ErrorStore.setErrorMessage'); 35 | try { 36 | return super.setErrorMessage(message); 37 | } finally { 38 | _$_ErrorStoreActionController.endAction(_$actionInfo); 39 | } 40 | } 41 | 42 | @override 43 | void reset(String value) { 44 | final _$actionInfo = 45 | _$_ErrorStoreActionController.startAction(name: '_ErrorStore.reset'); 46 | try { 47 | return super.reset(value); 48 | } finally { 49 | _$_ErrorStoreActionController.endAction(_$actionInfo); 50 | } 51 | } 52 | 53 | @override 54 | dynamic dispose() { 55 | final _$actionInfo = 56 | _$_ErrorStoreActionController.startAction(name: '_ErrorStore.dispose'); 57 | try { 58 | return super.dispose(); 59 | } finally { 60 | _$_ErrorStoreActionController.endAction(_$actionInfo); 61 | } 62 | } 63 | 64 | @override 65 | String toString() { 66 | return ''' 67 | errorMessage: ${errorMessage} 68 | '''; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/core/stores/form/form_store.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/stores/error/error_store.dart'; 2 | import 'package:mobx/mobx.dart'; 3 | import 'package:validators/validators.dart'; 4 | 5 | part 'form_store.g.dart'; 6 | 7 | class FormStore = _FormStore with _$FormStore; 8 | 9 | abstract class _FormStore with Store { 10 | // store for handling form errors 11 | final FormErrorStore formErrorStore; 12 | 13 | // store for handling error messages 14 | final ErrorStore errorStore; 15 | 16 | _FormStore(this.formErrorStore, this.errorStore) { 17 | _setupValidations(); 18 | } 19 | 20 | // disposers:----------------------------------------------------------------- 21 | late List _disposers; 22 | 23 | void _setupValidations() { 24 | _disposers = [ 25 | reaction((_) => userEmail, validateUserEmail), 26 | reaction((_) => password, validatePassword), 27 | reaction((_) => confirmPassword, validateConfirmPassword) 28 | ]; 29 | } 30 | 31 | // store variables:----------------------------------------------------------- 32 | @observable 33 | String userEmail = ''; 34 | 35 | @observable 36 | String password = ''; 37 | 38 | @observable 39 | String confirmPassword = ''; 40 | 41 | @observable 42 | bool success = false; 43 | 44 | @computed 45 | bool get canLogin => 46 | !formErrorStore.hasErrorsInLogin && userEmail.isNotEmpty && password.isNotEmpty; 47 | 48 | @computed 49 | bool get canRegister => 50 | !formErrorStore.hasErrorsInRegister && 51 | userEmail.isNotEmpty && 52 | password.isNotEmpty && 53 | confirmPassword.isNotEmpty; 54 | 55 | @computed 56 | bool get canForgetPassword => 57 | !formErrorStore.hasErrorInForgotPassword && userEmail.isNotEmpty; 58 | 59 | // actions:------------------------------------------------------------------- 60 | @action 61 | void setUserId(String value) { 62 | userEmail = value; 63 | } 64 | 65 | @action 66 | void setPassword(String value) { 67 | password = value; 68 | } 69 | 70 | @action 71 | void setConfirmPassword(String value) { 72 | confirmPassword = value; 73 | } 74 | 75 | @action 76 | void validateUserEmail(String value) { 77 | if (value.isEmpty) { 78 | formErrorStore.userEmail = "Email can't be empty"; 79 | } else if (!isEmail(value)) { 80 | formErrorStore.userEmail = 'Please enter a valid email address'; 81 | } else { 82 | formErrorStore.userEmail = null; 83 | } 84 | } 85 | 86 | @action 87 | void validatePassword(String value) { 88 | if (value.isEmpty) { 89 | formErrorStore.password = "Password can't be empty"; 90 | } else if (value.length < 6) { 91 | formErrorStore.password = "Password must be at-least 6 characters long"; 92 | } else { 93 | formErrorStore.password = null; 94 | } 95 | } 96 | 97 | @action 98 | void validateConfirmPassword(String value) { 99 | if (value.isEmpty) { 100 | formErrorStore.confirmPassword = "Confirm password can't be empty"; 101 | } else if (value != password) { 102 | formErrorStore.confirmPassword = "Password doesn't match"; 103 | } else { 104 | formErrorStore.confirmPassword = null; 105 | } 106 | } 107 | 108 | // general methods:----------------------------------------------------------- 109 | void dispose() { 110 | for (final d in _disposers) { 111 | d(); 112 | } 113 | } 114 | 115 | void validateAll() { 116 | validatePassword(password); 117 | validateUserEmail(userEmail); 118 | } 119 | } 120 | 121 | class FormErrorStore = _FormErrorStore with _$FormErrorStore; 122 | 123 | abstract class _FormErrorStore with Store { 124 | @observable 125 | String? userEmail; 126 | 127 | @observable 128 | String? password; 129 | 130 | @observable 131 | String? confirmPassword; 132 | 133 | @computed 134 | bool get hasErrorsInLogin => userEmail != null || password != null; 135 | 136 | @computed 137 | bool get hasErrorsInRegister => 138 | userEmail != null || password != null || confirmPassword != null; 139 | 140 | @computed 141 | bool get hasErrorInForgotPassword => userEmail != null; 142 | } 143 | -------------------------------------------------------------------------------- /lib/core/widgets/app_icon_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class AppIconWidget extends StatelessWidget { 4 | final image; 5 | 6 | const AppIconWidget({ 7 | Key? key, 8 | this.image, 9 | }) : super(key: key); 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | //getting screen size 14 | var size = MediaQuery.of(context).size; 15 | 16 | //calculating container width 17 | double imageSize; 18 | if (MediaQuery.of(context).orientation == Orientation.portrait) { 19 | imageSize = (size.width * 0.20); 20 | } else { 21 | imageSize = (size.height * 0.20); 22 | } 23 | 24 | return Image.asset( 25 | image, 26 | height: imageSize, 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/core/widgets/empty_app_bar_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class EmptyAppBar extends StatelessWidget implements PreferredSizeWidget { 4 | @override 5 | Widget build(BuildContext context) { 6 | return Container(); 7 | } 8 | 9 | @override 10 | Size get preferredSize => Size(0.0, 0.0); 11 | } 12 | -------------------------------------------------------------------------------- /lib/core/widgets/progress_indicator_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class CustomProgressIndicatorWidget extends StatelessWidget { 4 | const CustomProgressIndicatorWidget({ 5 | Key? key, 6 | }) : super(key: key); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Align( 11 | alignment: Alignment.center, 12 | child: Container( 13 | height: 100, 14 | constraints: BoxConstraints.expand(), 15 | child: FittedBox( 16 | fit: BoxFit.none, 17 | child: SizedBox( 18 | height: 100, 19 | width: 100, 20 | child: Card( 21 | child: Padding( 22 | padding: const EdgeInsets.all(25.0), 23 | child: CircularProgressIndicator(), 24 | ), 25 | shape: RoundedRectangleBorder( 26 | borderRadius: BorderRadius.circular(10.0)), 27 | ), 28 | ), 29 | ), 30 | decoration: BoxDecoration( 31 | color: Color.fromARGB(100, 105, 105, 105)), 32 | ), 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/core/widgets/rounded_button_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class RoundedButtonWidget extends StatelessWidget { 4 | final String? buttonText; 5 | final Color? buttonColor; 6 | final Color textColor; 7 | final Color? borderColor; 8 | final String? imagePath; 9 | final double buttonTextSize; 10 | final double? height; 11 | final VoidCallback? onPressed; 12 | final ShapeBorder shape; 13 | 14 | const RoundedButtonWidget({ 15 | Key? key, 16 | this.buttonText, 17 | this.buttonColor, 18 | this.textColor = Colors.white, 19 | this.onPressed, 20 | this.imagePath, 21 | this.borderColor, 22 | this.shape = const StadiumBorder(), 23 | this.buttonTextSize = 14.0, 24 | this.height, 25 | }) : super(key: key); 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | return MaterialButton( 30 | height: height, 31 | key: this.key, 32 | color: buttonColor, 33 | shape: borderColor != null 34 | ? StadiumBorder(side: BorderSide(color: borderColor!)) 35 | : shape, 36 | onPressed: onPressed, 37 | child: Row( 38 | mainAxisAlignment: MainAxisAlignment.center, 39 | children: [ 40 | imagePath != null 41 | ? Image.asset( 42 | imagePath!, 43 | height: 15.0, 44 | ) 45 | : SizedBox.shrink(), 46 | SizedBox(width: 5.0), 47 | Text( 48 | buttonText!, 49 | overflow: TextOverflow.clip, 50 | style: TextStyle( 51 | color: textColor, 52 | fontWeight: FontWeight.normal, 53 | fontSize: buttonTextSize, 54 | ), 55 | ), 56 | ], 57 | ), 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/core/widgets/textfield_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class TextFieldWidget extends StatelessWidget { 4 | final IconData icon; 5 | final String? hint; 6 | final String? errorText; 7 | final bool isObscure; 8 | final bool isIcon; 9 | final TextInputType? inputType; 10 | final TextEditingController textController; 11 | final EdgeInsets padding; 12 | final Color hintColor; 13 | final Color iconColor; 14 | final FocusNode? focusNode; 15 | final ValueChanged? onFieldSubmitted; 16 | final ValueChanged? onChanged; 17 | final bool autoFocus; 18 | final TextInputAction? inputAction; 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | return Padding( 23 | padding: padding, 24 | child: TextFormField( 25 | controller: textController, 26 | focusNode: focusNode, 27 | onFieldSubmitted: onFieldSubmitted, 28 | onChanged: onChanged, 29 | autofocus: autoFocus, 30 | textInputAction: inputAction, 31 | obscureText: this.isObscure, 32 | maxLength: 25, 33 | keyboardType: this.inputType, 34 | style: Theme.of(context).textTheme.bodyLarge, 35 | decoration: InputDecoration( 36 | hintText: this.hint, 37 | hintStyle: Theme.of(context) 38 | .textTheme 39 | .bodyLarge! 40 | .copyWith(color: hintColor), 41 | errorText: errorText, 42 | counterText: '', 43 | icon: this.isIcon ? Icon(this.icon, color: iconColor) : null), 44 | ), 45 | ); 46 | } 47 | 48 | const TextFieldWidget({ 49 | Key? key, 50 | required this.icon, 51 | required this.errorText, 52 | required this.textController, 53 | this.inputType, 54 | this.hint, 55 | this.isObscure = false, 56 | this.isIcon = true, 57 | this.padding = const EdgeInsets.all(0), 58 | this.hintColor = Colors.grey, 59 | this.iconColor = Colors.grey, 60 | this.focusNode, 61 | this.onFieldSubmitted, 62 | this.onChanged, 63 | this.autoFocus = false, 64 | this.inputAction, 65 | }) : super(key: key); 66 | } 67 | -------------------------------------------------------------------------------- /lib/data/di/data_layer_injection.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/data/di/module/local_module.dart'; 2 | import 'package:boilerplate/data/di/module/network_module.dart'; 3 | import 'package:boilerplate/data/di/module/repository_module.dart'; 4 | 5 | class DataLayerInjection { 6 | static Future configureDataLayerInjection() async { 7 | await LocalModule.configureLocalModuleInjection(); 8 | await NetworkModule.configureNetworkModuleInjection(); 9 | await RepositoryModule.configureRepositoryModuleInjection(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/data/di/module/local_module.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/core/data/local/sembast/sembast_client.dart'; 4 | import 'package:boilerplate/data/local/constants/db_constants.dart'; 5 | import 'package:boilerplate/data/local/datasources/post/post_datasource.dart'; 6 | import 'package:boilerplate/data/sharedpref/shared_preference_helper.dart'; 7 | import 'package:flutter/foundation.dart'; 8 | import 'package:path_provider/path_provider.dart'; 9 | import 'package:shared_preferences/shared_preferences.dart'; 10 | 11 | import '../../../di/service_locator.dart'; 12 | 13 | class LocalModule { 14 | static Future configureLocalModuleInjection() async { 15 | // preference manager:------------------------------------------------------ 16 | getIt.registerSingletonAsync( 17 | SharedPreferences.getInstance); 18 | getIt.registerSingleton( 19 | SharedPreferenceHelper(await getIt.getAsync()), 20 | ); 21 | 22 | // database:---------------------------------------------------------------- 23 | 24 | getIt.registerSingletonAsync( 25 | () async => SembastClient.provideDatabase( 26 | databaseName: DBConstants.DB_NAME, 27 | databasePath: kIsWeb 28 | ? "/assets/db" 29 | : (await getApplicationDocumentsDirectory()).path, 30 | ), 31 | ); 32 | 33 | // data sources:------------------------------------------------------------ 34 | getIt.registerSingleton( 35 | PostDataSource(await getIt.getAsync())); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/data/di/module/network_module.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/data/network/dio/configs/dio_configs.dart'; 2 | import 'package:boilerplate/core/data/network/dio/dio_client.dart'; 3 | import 'package:boilerplate/core/data/network/dio/interceptors/auth_interceptor.dart'; 4 | import 'package:boilerplate/core/data/network/dio/interceptors/logging_interceptor.dart'; 5 | import 'package:boilerplate/data/network/apis/posts/post_api.dart'; 6 | import 'package:boilerplate/data/network/constants/endpoints.dart'; 7 | import 'package:boilerplate/data/network/interceptors/error_interceptor.dart'; 8 | import 'package:boilerplate/data/network/rest_client.dart'; 9 | import 'package:boilerplate/data/sharedpref/shared_preference_helper.dart'; 10 | import 'package:event_bus/event_bus.dart'; 11 | 12 | import '../../../di/service_locator.dart'; 13 | 14 | class NetworkModule { 15 | static Future configureNetworkModuleInjection() async { 16 | // event bus:--------------------------------------------------------------- 17 | getIt.registerSingleton(EventBus()); 18 | 19 | // interceptors:------------------------------------------------------------ 20 | getIt.registerSingleton(LoggingInterceptor()); 21 | getIt.registerSingleton(ErrorInterceptor(getIt())); 22 | getIt.registerSingleton( 23 | AuthInterceptor( 24 | accessToken: () async => await getIt().authToken, 25 | ), 26 | ); 27 | 28 | // rest client:------------------------------------------------------------- 29 | getIt.registerSingleton(RestClient()); 30 | 31 | // dio:--------------------------------------------------------------------- 32 | getIt.registerSingleton( 33 | const DioConfigs( 34 | baseUrl: Endpoints.baseUrl, 35 | connectionTimeout: Endpoints.connectionTimeout, 36 | receiveTimeout:Endpoints.receiveTimeout, 37 | ), 38 | ); 39 | getIt.registerSingleton( 40 | DioClient(dioConfigs: getIt()) 41 | ..addInterceptors( 42 | [ 43 | getIt(), 44 | getIt(), 45 | getIt(), 46 | ], 47 | ), 48 | ); 49 | 50 | // api's:------------------------------------------------------------------- 51 | getIt.registerSingleton(PostApi(getIt(), getIt())); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lib/data/di/module/repository_module.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/data/local/datasources/post/post_datasource.dart'; 4 | import 'package:boilerplate/data/network/apis/posts/post_api.dart'; 5 | import 'package:boilerplate/data/repository/post/post_repository_impl.dart'; 6 | import 'package:boilerplate/data/repository/setting/setting_repository_impl.dart'; 7 | import 'package:boilerplate/data/repository/user/user_repository_impl.dart'; 8 | import 'package:boilerplate/data/sharedpref/shared_preference_helper.dart'; 9 | import 'package:boilerplate/domain/repository/post/post_repository.dart'; 10 | import 'package:boilerplate/domain/repository/setting/setting_repository.dart'; 11 | import 'package:boilerplate/domain/repository/user/user_repository.dart'; 12 | 13 | import '../../../di/service_locator.dart'; 14 | 15 | class RepositoryModule { 16 | static Future configureRepositoryModuleInjection() async { 17 | // repository:-------------------------------------------------------------- 18 | getIt.registerSingleton(SettingRepositoryImpl( 19 | getIt(), 20 | )); 21 | 22 | getIt.registerSingleton(UserRepositoryImpl( 23 | getIt(), 24 | )); 25 | 26 | getIt.registerSingleton(PostRepositoryImpl( 27 | getIt(), 28 | getIt(), 29 | )); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/data/local/constants/db_constants.dart: -------------------------------------------------------------------------------- 1 | class DBConstants { 2 | DBConstants._(); 3 | 4 | // Store Name 5 | static const String STORE_NAME = 'demo'; 6 | 7 | // DB Name 8 | static const DB_NAME = 'demo.db'; 9 | 10 | // Fields 11 | static const FIELD_ID = 'id'; 12 | } 13 | -------------------------------------------------------------------------------- /lib/data/local/datasources/post/post_datasource.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/data/local/sembast/sembast_client.dart'; 2 | import 'package:boilerplate/data/local/constants/db_constants.dart'; 3 | import 'package:boilerplate/domain/entity/post/post.dart'; 4 | import 'package:boilerplate/domain/entity/post/post_list.dart'; 5 | import 'package:sembast/sembast.dart'; 6 | 7 | class PostDataSource { 8 | // A Store with int keys and Map values. 9 | // This Store acts like a persistent map, values of which are Flogs objects converted to Map 10 | final _postsStore = intMapStoreFactory.store(DBConstants.STORE_NAME); 11 | 12 | // Private getter to shorten the amount of code needed to get the 13 | // singleton instance of an opened database. 14 | // Future get _db async => await AppDatabase.instance.database; 15 | 16 | // database instance 17 | final SembastClient _sembastClient; 18 | 19 | // Constructor 20 | PostDataSource(this._sembastClient); 21 | 22 | // DB functions:-------------------------------------------------------------- 23 | Future insert(Post post) async { 24 | return await _postsStore.add(_sembastClient.database, post.toMap()); 25 | } 26 | 27 | Future count() async { 28 | return await _postsStore.count(_sembastClient.database); 29 | } 30 | 31 | Future> getAllSortedByFilter({List? filters}) async { 32 | //creating finder 33 | final finder = Finder( 34 | filter: filters != null ? Filter.and(filters) : null, 35 | sortOrders: [SortOrder(DBConstants.FIELD_ID)]); 36 | 37 | final recordSnapshots = await _postsStore.find( 38 | _sembastClient.database, 39 | finder: finder, 40 | ); 41 | 42 | // Making a List out of List 43 | return recordSnapshots.map((snapshot) { 44 | final post = Post.fromMap(snapshot.value); 45 | // An ID is a key of a record from the database. 46 | post.id = snapshot.key; 47 | return post; 48 | }).toList(); 49 | } 50 | 51 | Future getPostsFromDb() async { 52 | 53 | print('Loading from database'); 54 | 55 | // post list 56 | var postsList; 57 | 58 | // fetching data 59 | final recordSnapshots = await _postsStore.find( 60 | _sembastClient.database, 61 | ); 62 | 63 | // Making a List out of List 64 | if(recordSnapshots.length > 0) { 65 | postsList = PostList( 66 | posts: recordSnapshots.map((snapshot) { 67 | final post = Post.fromMap(snapshot.value); 68 | // An ID is a key of a record from the database. 69 | post.id = snapshot.key; 70 | return post; 71 | }).toList()); 72 | } 73 | 74 | return postsList; 75 | } 76 | 77 | Future update(Post post) async { 78 | // For filtering by key (ID), RegEx, greater than, and many other criteria, 79 | // we use a Finder. 80 | final finder = Finder(filter: Filter.byKey(post.id)); 81 | return await _postsStore.update( 82 | _sembastClient.database, 83 | post.toMap(), 84 | finder: finder, 85 | ); 86 | } 87 | 88 | Future delete(Post post) async { 89 | final finder = Finder(filter: Filter.byKey(post.id)); 90 | return await _postsStore.delete( 91 | _sembastClient.database, 92 | finder: finder, 93 | ); 94 | } 95 | 96 | Future deleteAll() async { 97 | await _postsStore.drop( 98 | _sembastClient.database, 99 | ); 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /lib/data/network/apis/posts/post_api.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/core/data/network/dio/dio_client.dart'; 4 | import 'package:boilerplate/data/network/constants/endpoints.dart'; 5 | import 'package:boilerplate/data/network/rest_client.dart'; 6 | import 'package:boilerplate/domain/entity/post/post_list.dart'; 7 | 8 | class PostApi { 9 | // dio instance 10 | final DioClient _dioClient; 11 | 12 | // rest-client instance 13 | final RestClient _restClient; 14 | 15 | // injecting dio instance 16 | PostApi(this._dioClient, this._restClient); 17 | 18 | /// Returns list of post in response 19 | Future getPosts() async { 20 | try { 21 | final res = await _dioClient.dio.get(Endpoints.getPosts); 22 | return PostList.fromJson(res.data); 23 | } catch (e) { 24 | print(e.toString()); 25 | throw e; 26 | } 27 | } 28 | 29 | /// sample api call with default rest client 30 | // Future getPosts() async { 31 | // try { 32 | // final res = await _restClient.get(Endpoints.getPosts); 33 | // return PostList.fromJson(res.data); 34 | // } catch (e) { 35 | // print(e.toString()); 36 | // throw e; 37 | // } 38 | // } 39 | } 40 | -------------------------------------------------------------------------------- /lib/data/network/constants/endpoints.dart: -------------------------------------------------------------------------------- 1 | class Endpoints { 2 | Endpoints._(); 3 | 4 | // base url 5 | static const String baseUrl = "http://jsonplaceholder.typicode.com"; 6 | 7 | // receiveTimeout 8 | static const int receiveTimeout = 15000; 9 | 10 | // connectTimeout 11 | static const int connectionTimeout = 30000; 12 | 13 | // booking endpoints 14 | static const String getPosts = baseUrl + "/posts"; 15 | } -------------------------------------------------------------------------------- /lib/data/network/dio_client.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | class DioClient { 4 | // dio instance 5 | final Dio _dio; 6 | 7 | // injecting dio instance 8 | DioClient(this._dio); 9 | 10 | // Get:----------------------------------------------------------------------- 11 | Future get( 12 | String uri, { 13 | Map? queryParameters, 14 | Options? options, 15 | CancelToken? cancelToken, 16 | ProgressCallback? onReceiveProgress, 17 | }) async { 18 | try { 19 | final Response response = await _dio.get( 20 | uri, 21 | queryParameters: queryParameters, 22 | options: options, 23 | cancelToken: cancelToken, 24 | onReceiveProgress: onReceiveProgress, 25 | ); 26 | return response.data; 27 | } catch (e) { 28 | print(e.toString()); 29 | throw e; 30 | } 31 | } 32 | 33 | // Post:---------------------------------------------------------------------- 34 | Future post( 35 | String uri, { 36 | data, 37 | Map? queryParameters, 38 | Options? options, 39 | CancelToken? cancelToken, 40 | ProgressCallback? onSendProgress, 41 | ProgressCallback? onReceiveProgress, 42 | }) async { 43 | try { 44 | final Response response = await _dio.post( 45 | uri, 46 | data: data, 47 | queryParameters: queryParameters, 48 | options: options, 49 | cancelToken: cancelToken, 50 | onSendProgress: onSendProgress, 51 | onReceiveProgress: onReceiveProgress, 52 | ); 53 | return response.data; 54 | } catch (e) { 55 | throw e; 56 | } 57 | } 58 | 59 | // Put:----------------------------------------------------------------------- 60 | Future put( 61 | String uri, { 62 | data, 63 | Map? queryParameters, 64 | Options? options, 65 | CancelToken? cancelToken, 66 | ProgressCallback? onSendProgress, 67 | ProgressCallback? onReceiveProgress, 68 | }) async { 69 | try { 70 | final Response response = await _dio.put( 71 | uri, 72 | data: data, 73 | queryParameters: queryParameters, 74 | options: options, 75 | cancelToken: cancelToken, 76 | onSendProgress: onSendProgress, 77 | onReceiveProgress: onReceiveProgress, 78 | ); 79 | return response.data; 80 | } catch (e) { 81 | throw e; 82 | } 83 | } 84 | 85 | // Delete:-------------------------------------------------------------------- 86 | Future delete( 87 | String uri, { 88 | data, 89 | Map? queryParameters, 90 | Options? options, 91 | CancelToken? cancelToken, 92 | ProgressCallback? onSendProgress, 93 | ProgressCallback? onReceiveProgress, 94 | }) async { 95 | try { 96 | final Response response = await _dio.delete( 97 | uri, 98 | data: data, 99 | queryParameters: queryParameters, 100 | options: options, 101 | cancelToken: cancelToken, 102 | ); 103 | return response.data; 104 | } catch (e) { 105 | throw e; 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /lib/data/network/exceptions/network_exceptions.dart: -------------------------------------------------------------------------------- 1 | class NetworkException implements Exception { 2 | String? message; 3 | int? statusCode; 4 | 5 | NetworkException({this.message, this.statusCode}); 6 | } 7 | 8 | class AuthException extends NetworkException { 9 | AuthException({message, statusCode}) 10 | : super(message: message, statusCode: statusCode); 11 | } 12 | -------------------------------------------------------------------------------- /lib/data/network/interceptors/error_interceptor.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:event_bus/event_bus.dart'; 3 | 4 | class ErrorInterceptor extends Interceptor { 5 | final EventBus _eventBus; 6 | 7 | ErrorInterceptor(this._eventBus); 8 | 9 | @override 10 | void onError(DioException err, ErrorInterceptorHandler handler) { 11 | _eventBus.fire( 12 | ErrorEvent(path: err.requestOptions.path, response: err.response), 13 | ); 14 | super.onError(err, handler); 15 | } 16 | } 17 | 18 | class ErrorEvent { 19 | final String path; 20 | final Response? response; 21 | 22 | ErrorEvent({required this.path, this.response}); 23 | } 24 | -------------------------------------------------------------------------------- /lib/data/network/rest_client.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:convert'; 3 | 4 | import 'package:http/http.dart' as http; 5 | 6 | import 'exceptions/network_exceptions.dart'; 7 | 8 | class RestClient { 9 | // instantiate json decoder for json serialization 10 | final JsonDecoder _decoder = JsonDecoder(); 11 | 12 | // Get:----------------------------------------------------------------------- 13 | Future get(String path) { 14 | return http.get(Uri.parse(path)).then(_createResponse); 15 | } 16 | 17 | // Post:---------------------------------------------------------------------- 18 | Future post(String path, 19 | {Map? headers, body, encoding}) { 20 | return http 21 | .post( 22 | Uri.parse(path), 23 | body: body, 24 | headers: headers, 25 | encoding: encoding, 26 | ) 27 | .then(_createResponse); 28 | } 29 | 30 | // Put:---------------------------------------------------------------------- 31 | Future put(String path, 32 | {Map? headers, body, encoding}) { 33 | return http 34 | .put( 35 | Uri.parse(path), 36 | body: body, 37 | headers: headers, 38 | encoding: encoding, 39 | ) 40 | .then(_createResponse); 41 | } 42 | 43 | // Delete:---------------------------------------------------------------------- 44 | Future delete(String path, 45 | {Map? headers, body, encoding}) { 46 | return http 47 | .delete( 48 | Uri.parse(path), 49 | body: body, 50 | headers: headers, 51 | encoding: encoding, 52 | ) 53 | .then(_createResponse); 54 | } 55 | 56 | // Response:------------------------------------------------------------------ 57 | dynamic _createResponse(http.Response response) { 58 | final String res = response.body; 59 | final int statusCode = response.statusCode; 60 | 61 | if (statusCode < 200 || statusCode > 400) { 62 | throw NetworkException( 63 | message: 'Error fetching data from server', statusCode: statusCode); 64 | } 65 | 66 | return _decoder.convert(res); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/data/repository/post/post_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/data/local/constants/db_constants.dart'; 4 | import 'package:boilerplate/data/local/datasources/post/post_datasource.dart'; 5 | import 'package:boilerplate/data/network/apis/posts/post_api.dart'; 6 | import 'package:boilerplate/domain/entity/post/post.dart'; 7 | import 'package:boilerplate/domain/entity/post/post_list.dart'; 8 | import 'package:boilerplate/domain/repository/post/post_repository.dart'; 9 | import 'package:sembast/sembast.dart'; 10 | 11 | class PostRepositoryImpl extends PostRepository { 12 | // data source object 13 | final PostDataSource _postDataSource; 14 | 15 | // api objects 16 | final PostApi _postApi; 17 | 18 | // constructor 19 | PostRepositoryImpl(this._postApi, this._postDataSource); 20 | 21 | // Post: --------------------------------------------------------------------- 22 | @override 23 | Future getPosts() async { 24 | return await _postApi.getPosts().then((postsList) { 25 | postsList.posts?.forEach((post) { 26 | _postDataSource.insert(post); 27 | }); 28 | 29 | return postsList; 30 | }).catchError((error) => throw error); 31 | } 32 | 33 | @override 34 | Future> findPostById(int id) { 35 | //creating filter 36 | List filters = []; 37 | 38 | //check to see if dataLogsType is not null 39 | Filter dataLogTypeFilter = Filter.equals(DBConstants.FIELD_ID, id); 40 | filters.add(dataLogTypeFilter); 41 | 42 | //making db call 43 | return _postDataSource 44 | .getAllSortedByFilter(filters: filters) 45 | .then((posts) => posts) 46 | .catchError((error) => throw error); 47 | } 48 | 49 | @override 50 | Future insert(Post post) => _postDataSource 51 | .insert(post) 52 | .then((id) => id) 53 | .catchError((error) => throw error); 54 | 55 | @override 56 | Future update(Post post) => _postDataSource 57 | .update(post) 58 | .then((id) => id) 59 | .catchError((error) => throw error); 60 | 61 | @override 62 | Future delete(Post post) => _postDataSource 63 | .delete(post) 64 | .then((id) => id) 65 | .catchError((error) => throw error); 66 | } 67 | -------------------------------------------------------------------------------- /lib/data/repository/setting/setting_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/domain/repository/setting/setting_repository.dart'; 4 | import 'package:boilerplate/data/sharedpref/shared_preference_helper.dart'; 5 | 6 | class SettingRepositoryImpl extends SettingRepository { 7 | // shared pref object 8 | final SharedPreferenceHelper _sharedPrefsHelper; 9 | 10 | // constructor 11 | SettingRepositoryImpl(this._sharedPrefsHelper); 12 | 13 | // Theme: -------------------------------------------------------------------- 14 | @override 15 | Future changeBrightnessToDark(bool value) => 16 | _sharedPrefsHelper.changeBrightnessToDark(value); 17 | 18 | @override 19 | bool get isDarkMode => _sharedPrefsHelper.isDarkMode; 20 | 21 | // Language: ----------------------------------------------------------------- 22 | @override 23 | Future changeLanguage(String value) => 24 | _sharedPrefsHelper.changeLanguage(value); 25 | 26 | @override 27 | String? get currentLanguage => _sharedPrefsHelper.currentLanguage; 28 | } 29 | -------------------------------------------------------------------------------- /lib/data/repository/user/user_repository_impl.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/domain/repository/user/user_repository.dart'; 4 | import 'package:boilerplate/data/sharedpref/shared_preference_helper.dart'; 5 | 6 | import '../../../domain/entity/user/user.dart'; 7 | import '../../../domain/usecase/user/login_usecase.dart'; 8 | 9 | class UserRepositoryImpl extends UserRepository { 10 | // shared pref object 11 | final SharedPreferenceHelper _sharedPrefsHelper; 12 | 13 | // constructor 14 | UserRepositoryImpl(this._sharedPrefsHelper); 15 | 16 | // Login:--------------------------------------------------------------------- 17 | @override 18 | Future login(LoginParams params) async { 19 | return await Future.delayed(Duration(seconds: 2), () => User()); 20 | } 21 | 22 | @override 23 | Future saveIsLoggedIn(bool value) => 24 | _sharedPrefsHelper.saveIsLoggedIn(value); 25 | 26 | @override 27 | Future get isLoggedIn => _sharedPrefsHelper.isLoggedIn; 28 | } 29 | -------------------------------------------------------------------------------- /lib/data/sharedpref/constants/preferences.dart: -------------------------------------------------------------------------------- 1 | class Preferences { 2 | Preferences._(); 3 | 4 | static const String is_logged_in = "isLoggedIn"; 5 | static const String auth_token = "authToken"; 6 | static const String is_dark_mode = "is_dark_mode"; 7 | static const String current_language = "current_language"; 8 | } -------------------------------------------------------------------------------- /lib/data/sharedpref/shared_preference_helper.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:shared_preferences/shared_preferences.dart'; 4 | 5 | import 'constants/preferences.dart'; 6 | 7 | class SharedPreferenceHelper { 8 | // shared pref instance 9 | final SharedPreferences _sharedPreference; 10 | 11 | // constructor 12 | SharedPreferenceHelper(this._sharedPreference); 13 | 14 | // General Methods: ---------------------------------------------------------- 15 | Future get authToken async { 16 | return _sharedPreference.getString(Preferences.auth_token); 17 | } 18 | 19 | Future saveAuthToken(String authToken) async { 20 | return _sharedPreference.setString(Preferences.auth_token, authToken); 21 | } 22 | 23 | Future removeAuthToken() async { 24 | return _sharedPreference.remove(Preferences.auth_token); 25 | } 26 | 27 | // Login:--------------------------------------------------------------------- 28 | Future get isLoggedIn async { 29 | return _sharedPreference.getBool(Preferences.is_logged_in) ?? false; 30 | } 31 | 32 | Future saveIsLoggedIn(bool value) async { 33 | return _sharedPreference.setBool(Preferences.is_logged_in, value); 34 | } 35 | 36 | // Theme:------------------------------------------------------ 37 | bool get isDarkMode { 38 | return _sharedPreference.getBool(Preferences.is_dark_mode) ?? false; 39 | } 40 | 41 | Future changeBrightnessToDark(bool value) { 42 | return _sharedPreference.setBool(Preferences.is_dark_mode, value); 43 | } 44 | 45 | // Language:--------------------------------------------------- 46 | String? get currentLanguage { 47 | return _sharedPreference.getString(Preferences.current_language); 48 | } 49 | 50 | Future changeLanguage(String language) { 51 | return _sharedPreference.setString(Preferences.current_language, language); 52 | } 53 | } -------------------------------------------------------------------------------- /lib/di/service_locator.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/data/di/data_layer_injection.dart'; 2 | import 'package:boilerplate/domain/di/domain_layer_injection.dart'; 3 | import 'package:boilerplate/presentation/di/presentation_layer_injection.dart'; 4 | import 'package:get_it/get_it.dart'; 5 | 6 | final getIt = GetIt.instance; 7 | 8 | class ServiceLocator { 9 | static Future configureDependencies() async { 10 | await DataLayerInjection.configureDataLayerInjection(); 11 | await DomainLayerInjection.configureDomainLayerInjection(); 12 | await PresentationLayerInjection.configurePresentationLayerInjection(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/domain/di/domain_layer_injection.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/domain/di/module/usecase_module.dart'; 2 | 3 | class DomainLayerInjection { 4 | static Future configureDomainLayerInjection() async { 5 | await UseCaseModule.configureUseCaseModuleInjection(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/domain/di/module/usecase_module.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/domain/repository/post/post_repository.dart'; 4 | import 'package:boilerplate/domain/repository/user/user_repository.dart'; 5 | import 'package:boilerplate/domain/usecase/post/delete_post_usecase.dart'; 6 | import 'package:boilerplate/domain/usecase/post/find_post_by_id_usecase.dart'; 7 | import 'package:boilerplate/domain/usecase/post/get_post_usecase.dart'; 8 | import 'package:boilerplate/domain/usecase/post/insert_post_usecase.dart'; 9 | import 'package:boilerplate/domain/usecase/post/udpate_post_usecase.dart'; 10 | import 'package:boilerplate/domain/usecase/user/is_logged_in_usecase.dart'; 11 | import 'package:boilerplate/domain/usecase/user/login_usecase.dart'; 12 | import 'package:boilerplate/domain/usecase/user/save_login_in_status_usecase.dart'; 13 | 14 | import '../../../di/service_locator.dart'; 15 | 16 | class UseCaseModule { 17 | static Future configureUseCaseModuleInjection() async { 18 | // user:-------------------------------------------------------------------- 19 | getIt.registerSingleton( 20 | IsLoggedInUseCase(getIt()), 21 | ); 22 | getIt.registerSingleton( 23 | SaveLoginStatusUseCase(getIt()), 24 | ); 25 | getIt.registerSingleton( 26 | LoginUseCase(getIt()), 27 | ); 28 | 29 | // post:-------------------------------------------------------------------- 30 | getIt.registerSingleton( 31 | GetPostUseCase(getIt()), 32 | ); 33 | getIt.registerSingleton( 34 | FindPostByIdUseCase(getIt()), 35 | ); 36 | getIt.registerSingleton( 37 | InsertPostUseCase(getIt()), 38 | ); 39 | getIt.registerSingleton( 40 | UpdatePostUseCase(getIt()), 41 | ); 42 | getIt.registerSingleton( 43 | DeletePostUseCase(getIt()), 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/domain/entity/language/Language.dart: -------------------------------------------------------------------------------- 1 | class Language { 2 | /// the country code (IT,AF..) 3 | String code; 4 | 5 | /// the locale (en, es, da) 6 | String locale; 7 | 8 | /// the full name of language (English, Danish..) 9 | String language; 10 | 11 | /// map of keys used based on industry type (service worker, route etc) 12 | Map? dictionary; 13 | 14 | Language({ 15 | required this.code, 16 | required this.locale, 17 | required this.language, 18 | this.dictionary, 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /lib/domain/entity/post/post.dart: -------------------------------------------------------------------------------- 1 | class Post { 2 | int? userId; 3 | int? id; 4 | String? title; 5 | String? body; 6 | 7 | Post({ 8 | this.userId, 9 | this.id, 10 | this.title, 11 | this.body, 12 | }); 13 | 14 | factory Post.fromMap(Map json) => Post( 15 | userId: json["userId"], 16 | id: json["id"], 17 | title: json["title"], 18 | body: json["body"], 19 | ); 20 | 21 | Map toMap() => { 22 | "userId": userId, 23 | "id": id, 24 | "title": title, 25 | "body": body, 26 | }; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /lib/domain/entity/post/post_list.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/domain/entity/post/post.dart'; 2 | 3 | class PostList { 4 | final List? posts; 5 | 6 | PostList({ 7 | this.posts, 8 | }); 9 | 10 | factory PostList.fromJson(List json) { 11 | List posts = []; 12 | posts = json.map((post) => Post.fromMap(post)).toList(); 13 | 14 | return PostList( 15 | posts: posts, 16 | ); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/domain/entity/user/user.dart: -------------------------------------------------------------------------------- 1 | class User { 2 | 3 | } -------------------------------------------------------------------------------- /lib/domain/repository/post/post_repository.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/domain/entity/post/post.dart'; 4 | import 'package:boilerplate/domain/entity/post/post_list.dart'; 5 | 6 | abstract class PostRepository { 7 | Future getPosts(); 8 | 9 | Future> findPostById(int id); 10 | 11 | Future insert(Post post); 12 | 13 | Future update(Post post); 14 | 15 | Future delete(Post post); 16 | } 17 | -------------------------------------------------------------------------------- /lib/domain/repository/setting/setting_repository.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | abstract class SettingRepository { 4 | // Theme: -------------------------------------------------------------------- 5 | Future changeBrightnessToDark(bool value); 6 | 7 | bool get isDarkMode; 8 | 9 | // Language: ----------------------------------------------------------------- 10 | Future changeLanguage(String value); 11 | 12 | String? get currentLanguage; 13 | } 14 | -------------------------------------------------------------------------------- /lib/domain/repository/user/user_repository.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/domain/usecase/user/login_usecase.dart'; 4 | 5 | import '../../entity/user/user.dart'; 6 | 7 | abstract class UserRepository { 8 | Future login(LoginParams params); 9 | 10 | Future saveIsLoggedIn(bool value); 11 | 12 | Future get isLoggedIn; 13 | } 14 | -------------------------------------------------------------------------------- /lib/domain/usecase/post/delete_post_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/domain/usecase/use_case.dart'; 2 | import 'package:boilerplate/domain/entity/post/post.dart'; 3 | import 'package:boilerplate/domain/repository/post/post_repository.dart'; 4 | 5 | class DeletePostUseCase extends UseCase { 6 | final PostRepository _postRepository; 7 | 8 | DeletePostUseCase(this._postRepository); 9 | 10 | @override 11 | Future call({required params}) { 12 | return _postRepository.delete(params); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/domain/usecase/post/find_post_by_id_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/domain/usecase/use_case.dart'; 2 | import 'package:boilerplate/domain/entity/post/post.dart'; 3 | import 'package:boilerplate/domain/repository/post/post_repository.dart'; 4 | 5 | class FindPostByIdUseCase extends UseCase, int> { 6 | final PostRepository _postRepository; 7 | 8 | FindPostByIdUseCase(this._postRepository); 9 | 10 | @override 11 | Future> call({required int params}) { 12 | return _postRepository.findPostById(params); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/domain/usecase/post/get_post_usecase.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:boilerplate/core/domain/usecase/use_case.dart'; 3 | import 'package:boilerplate/domain/entity/post/post_list.dart'; 4 | import 'package:boilerplate/domain/repository/post/post_repository.dart'; 5 | 6 | class GetPostUseCase extends UseCase { 7 | 8 | final PostRepository _postRepository; 9 | 10 | GetPostUseCase(this._postRepository); 11 | 12 | @override 13 | Future call({required params}) { 14 | return _postRepository.getPosts(); 15 | } 16 | } -------------------------------------------------------------------------------- /lib/domain/usecase/post/insert_post_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/domain/usecase/use_case.dart'; 2 | import 'package:boilerplate/domain/entity/post/post.dart'; 3 | import 'package:boilerplate/domain/repository/post/post_repository.dart'; 4 | 5 | class InsertPostUseCase extends UseCase { 6 | final PostRepository _postRepository; 7 | 8 | InsertPostUseCase(this._postRepository); 9 | 10 | @override 11 | Future call({required params}) { 12 | return _postRepository.insert(params); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/domain/usecase/post/udpate_post_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/domain/usecase/use_case.dart'; 2 | import 'package:boilerplate/domain/entity/post/post.dart'; 3 | import 'package:boilerplate/domain/repository/post/post_repository.dart'; 4 | 5 | class UpdatePostUseCase extends UseCase { 6 | final PostRepository _postRepository; 7 | 8 | UpdatePostUseCase(this._postRepository); 9 | 10 | @override 11 | Future call({required params}) { 12 | return _postRepository.update(params); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/domain/usecase/user/is_logged_in_usecase.dart: -------------------------------------------------------------------------------- 1 | import '../../../core/domain/usecase/use_case.dart'; 2 | import '../../repository/user/user_repository.dart'; 3 | 4 | class IsLoggedInUseCase implements UseCase { 5 | final UserRepository _userRepository; 6 | 7 | IsLoggedInUseCase(this._userRepository); 8 | 9 | @override 10 | Future call({required void params}) async { 11 | return await _userRepository.isLoggedIn; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/domain/usecase/user/login_usecase.dart: -------------------------------------------------------------------------------- 1 | import '../../../core/domain/usecase/use_case.dart'; 2 | import '../../entity/user/user.dart'; 3 | import '../../repository/user/user_repository.dart'; 4 | import 'package:json_annotation/json_annotation.dart'; 5 | 6 | part 'login_usecase.g.dart'; 7 | 8 | @JsonSerializable() 9 | class LoginParams { 10 | final String username; 11 | final String password; 12 | 13 | LoginParams({required this.username, required this.password}); 14 | 15 | factory LoginParams.fromJson(Map json) => 16 | _$LoginParamsFromJson(json); 17 | 18 | Map toJson() => _$LoginParamsToJson(this); 19 | } 20 | 21 | class LoginUseCase implements UseCase { 22 | final UserRepository _userRepository; 23 | 24 | LoginUseCase(this._userRepository); 25 | 26 | @override 27 | Future call({required LoginParams params}) async { 28 | return _userRepository.login(params); 29 | } 30 | } -------------------------------------------------------------------------------- /lib/domain/usecase/user/login_usecase.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'login_usecase.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | LoginParams _$LoginParamsFromJson(Map json) => LoginParams( 10 | username: json['username'] as String, 11 | password: json['password'] as String, 12 | ); 13 | 14 | Map _$LoginParamsToJson(LoginParams instance) => 15 | { 16 | 'username': instance.username, 17 | 'password': instance.password, 18 | }; 19 | -------------------------------------------------------------------------------- /lib/domain/usecase/user/save_login_in_status_usecase.dart: -------------------------------------------------------------------------------- 1 | import '../../../core/domain/usecase/use_case.dart'; 2 | import '../../repository/user/user_repository.dart'; 3 | 4 | class SaveLoginStatusUseCase implements UseCase { 5 | final UserRepository _userRepository; 6 | 7 | SaveLoginStatusUseCase(this._userRepository); 8 | 9 | @override 10 | Future call({required bool params}) async { 11 | return _userRepository.saveIsLoggedIn(params); 12 | } 13 | } -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/di/service_locator.dart'; 4 | import 'package:boilerplate/presentation/my_app.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter/services.dart'; 7 | 8 | Future main() async { 9 | WidgetsFlutterBinding.ensureInitialized(); 10 | await setPreferredOrientations(); 11 | await ServiceLocator.configureDependencies(); 12 | runApp(MyApp()); 13 | } 14 | 15 | Future setPreferredOrientations() { 16 | return SystemChrome.setPreferredOrientations([ 17 | DeviceOrientation.portraitUp, 18 | DeviceOrientation.portraitDown, 19 | DeviceOrientation.landscapeRight, 20 | DeviceOrientation.landscapeLeft, 21 | ]); 22 | } 23 | -------------------------------------------------------------------------------- /lib/presentation/di/module/store_module.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:boilerplate/core/stores/error/error_store.dart'; 4 | import 'package:boilerplate/core/stores/form/form_store.dart'; 5 | import 'package:boilerplate/domain/repository/setting/setting_repository.dart'; 6 | import 'package:boilerplate/domain/usecase/post/get_post_usecase.dart'; 7 | import 'package:boilerplate/domain/usecase/user/is_logged_in_usecase.dart'; 8 | import 'package:boilerplate/domain/usecase/user/login_usecase.dart'; 9 | import 'package:boilerplate/domain/usecase/user/save_login_in_status_usecase.dart'; 10 | import 'package:boilerplate/presentation/home/store/language/language_store.dart'; 11 | import 'package:boilerplate/presentation/home/store/theme/theme_store.dart'; 12 | import 'package:boilerplate/presentation/login/store/login_store.dart'; 13 | import 'package:boilerplate/presentation/post/store/post_store.dart'; 14 | 15 | import '../../../di/service_locator.dart'; 16 | 17 | class StoreModule { 18 | static Future configureStoreModuleInjection() async { 19 | // factories:--------------------------------------------------------------- 20 | getIt.registerFactory(() => ErrorStore()); 21 | getIt.registerFactory(() => FormErrorStore()); 22 | getIt.registerFactory( 23 | () => FormStore(getIt(), getIt()), 24 | ); 25 | 26 | // stores:------------------------------------------------------------------ 27 | getIt.registerSingleton( 28 | UserStore( 29 | getIt(), 30 | getIt(), 31 | getIt(), 32 | getIt(), 33 | getIt(), 34 | ), 35 | ); 36 | 37 | getIt.registerSingleton( 38 | PostStore( 39 | getIt(), 40 | getIt(), 41 | ), 42 | ); 43 | 44 | getIt.registerSingleton( 45 | ThemeStore( 46 | getIt(), 47 | getIt(), 48 | ), 49 | ); 50 | 51 | getIt.registerSingleton( 52 | LanguageStore( 53 | getIt(), 54 | getIt(), 55 | ), 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/presentation/di/presentation_layer_injection.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/presentation/di/module/store_module.dart'; 2 | 3 | class PresentationLayerInjection { 4 | static Future configurePresentationLayerInjection() async { 5 | await StoreModule.configureStoreModuleInjection(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/presentation/home/store/language/language_store.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/stores/error/error_store.dart'; 2 | import 'package:boilerplate/domain/entity/language/Language.dart'; 3 | import 'package:boilerplate/domain/repository/setting/setting_repository.dart'; 4 | import 'package:mobx/mobx.dart'; 5 | 6 | part 'language_store.g.dart'; 7 | 8 | class LanguageStore = _LanguageStore with _$LanguageStore; 9 | 10 | abstract class _LanguageStore with Store { 11 | static const String TAG = "LanguageStore"; 12 | 13 | // repository instance 14 | final SettingRepository _repository; 15 | 16 | // store for handling errors 17 | final ErrorStore errorStore; 18 | 19 | // supported languages 20 | List supportedLanguages = [ 21 | Language(code: 'US', locale: 'en', language: 'English'), 22 | Language(code: 'DK', locale: 'da', language: 'Danish'), 23 | Language(code: 'ES', locale: 'es', language: 'España'), 24 | ]; 25 | 26 | // constructor:--------------------------------------------------------------- 27 | _LanguageStore(this._repository, this.errorStore) { 28 | init(); 29 | } 30 | 31 | // store variables:----------------------------------------------------------- 32 | @observable 33 | String _locale = "en"; 34 | 35 | @computed 36 | String get locale => _locale; 37 | 38 | // actions:------------------------------------------------------------------- 39 | @action 40 | void changeLanguage(String value) { 41 | _locale = value; 42 | _repository.changeLanguage(value).then((_) { 43 | // write additional logic here 44 | }); 45 | } 46 | 47 | @action 48 | String getCode() { 49 | var code; 50 | 51 | if (_locale == 'en') { 52 | code = "US"; 53 | } else if (_locale == 'da') { 54 | code = "DK"; 55 | } else if (_locale == 'es') { 56 | code = "ES"; 57 | } 58 | 59 | return code; 60 | } 61 | 62 | @action 63 | String? getLanguage() { 64 | return supportedLanguages[supportedLanguages 65 | .indexWhere((language) => language.locale == _locale)] 66 | .language; 67 | } 68 | 69 | // general:------------------------------------------------------------------- 70 | void init() async { 71 | // getting current language from shared preference 72 | if (_repository.currentLanguage != null) { 73 | _locale = _repository.currentLanguage!; 74 | } 75 | } 76 | 77 | // dispose:------------------------------------------------------------------- 78 | @override 79 | dispose() {} 80 | } 81 | -------------------------------------------------------------------------------- /lib/presentation/home/store/language/language_store.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'language_store.dart'; 4 | 5 | // ************************************************************************** 6 | // StoreGenerator 7 | // ************************************************************************** 8 | 9 | // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic, no_leading_underscores_for_local_identifiers 10 | 11 | mixin _$LanguageStore on _LanguageStore, Store { 12 | Computed? _$localeComputed; 13 | 14 | @override 15 | String get locale => (_$localeComputed ??= 16 | Computed(() => super.locale, name: '_LanguageStore.locale')) 17 | .value; 18 | 19 | late final _$_localeAtom = 20 | Atom(name: '_LanguageStore._locale', context: context); 21 | 22 | @override 23 | String get _locale { 24 | _$_localeAtom.reportRead(); 25 | return super._locale; 26 | } 27 | 28 | @override 29 | set _locale(String value) { 30 | _$_localeAtom.reportWrite(value, super._locale, () { 31 | super._locale = value; 32 | }); 33 | } 34 | 35 | late final _$_LanguageStoreActionController = 36 | ActionController(name: '_LanguageStore', context: context); 37 | 38 | @override 39 | void changeLanguage(String value) { 40 | final _$actionInfo = _$_LanguageStoreActionController.startAction( 41 | name: '_LanguageStore.changeLanguage'); 42 | try { 43 | return super.changeLanguage(value); 44 | } finally { 45 | _$_LanguageStoreActionController.endAction(_$actionInfo); 46 | } 47 | } 48 | 49 | @override 50 | String getCode() { 51 | final _$actionInfo = _$_LanguageStoreActionController.startAction( 52 | name: '_LanguageStore.getCode'); 53 | try { 54 | return super.getCode(); 55 | } finally { 56 | _$_LanguageStoreActionController.endAction(_$actionInfo); 57 | } 58 | } 59 | 60 | @override 61 | String? getLanguage() { 62 | final _$actionInfo = _$_LanguageStoreActionController.startAction( 63 | name: '_LanguageStore.getLanguage'); 64 | try { 65 | return super.getLanguage(); 66 | } finally { 67 | _$_LanguageStoreActionController.endAction(_$actionInfo); 68 | } 69 | } 70 | 71 | @override 72 | String toString() { 73 | return ''' 74 | locale: ${locale} 75 | '''; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/presentation/home/store/theme/theme_store.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/stores/error/error_store.dart'; 2 | import 'package:boilerplate/domain/repository/setting/setting_repository.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:mobx/mobx.dart'; 5 | 6 | part 'theme_store.g.dart'; 7 | 8 | class ThemeStore = _ThemeStore with _$ThemeStore; 9 | 10 | abstract class _ThemeStore with Store { 11 | final String TAG = "_ThemeStore"; 12 | 13 | // repository instance 14 | final SettingRepository _repository; 15 | 16 | // store for handling errors 17 | final ErrorStore errorStore; 18 | 19 | // store variables:----------------------------------------------------------- 20 | @observable 21 | bool _darkMode = false; 22 | 23 | // getters:------------------------------------------------------------------- 24 | bool get darkMode => _darkMode; 25 | 26 | // constructor:--------------------------------------------------------------- 27 | _ThemeStore(this._repository, this.errorStore) { 28 | init(); 29 | } 30 | 31 | // actions:------------------------------------------------------------------- 32 | @action 33 | Future changeBrightnessToDark(bool value) async { 34 | _darkMode = value; 35 | await _repository.changeBrightnessToDark(value); 36 | } 37 | 38 | // general methods:----------------------------------------------------------- 39 | Future init() async { 40 | _darkMode = _repository.isDarkMode; 41 | } 42 | 43 | bool isPlatformDark(BuildContext context) => 44 | MediaQuery.platformBrightnessOf(context) == Brightness.dark; 45 | 46 | // dispose:------------------------------------------------------------------- 47 | @override 48 | dispose() {} 49 | } 50 | -------------------------------------------------------------------------------- /lib/presentation/home/store/theme/theme_store.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'theme_store.dart'; 4 | 5 | // ************************************************************************** 6 | // StoreGenerator 7 | // ************************************************************************** 8 | 9 | // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic, no_leading_underscores_for_local_identifiers 10 | 11 | mixin _$ThemeStore on _ThemeStore, Store { 12 | late final _$_darkModeAtom = 13 | Atom(name: '_ThemeStore._darkMode', context: context); 14 | 15 | @override 16 | bool get _darkMode { 17 | _$_darkModeAtom.reportRead(); 18 | return super._darkMode; 19 | } 20 | 21 | @override 22 | set _darkMode(bool value) { 23 | _$_darkModeAtom.reportWrite(value, super._darkMode, () { 24 | super._darkMode = value; 25 | }); 26 | } 27 | 28 | late final _$changeBrightnessToDarkAsyncAction = 29 | AsyncAction('_ThemeStore.changeBrightnessToDark', context: context); 30 | 31 | @override 32 | Future changeBrightnessToDark(bool value) { 33 | return _$changeBrightnessToDarkAsyncAction 34 | .run(() => super.changeBrightnessToDark(value)); 35 | } 36 | 37 | @override 38 | String toString() { 39 | return ''' 40 | 41 | '''; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/presentation/login/store/login_store.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/stores/error/error_store.dart'; 2 | import 'package:boilerplate/core/stores/form/form_store.dart'; 3 | import 'package:boilerplate/domain/usecase/user/is_logged_in_usecase.dart'; 4 | import 'package:boilerplate/domain/usecase/user/save_login_in_status_usecase.dart'; 5 | import 'package:mobx/mobx.dart'; 6 | 7 | import '../../../domain/entity/user/user.dart'; 8 | import '../../../domain/usecase/user/login_usecase.dart'; 9 | 10 | part 'login_store.g.dart'; 11 | 12 | class UserStore = _UserStore with _$UserStore; 13 | 14 | abstract class _UserStore with Store { 15 | // constructor:--------------------------------------------------------------- 16 | _UserStore( 17 | this._isLoggedInUseCase, 18 | this._saveLoginStatusUseCase, 19 | this._loginUseCase, 20 | this.formErrorStore, 21 | this.errorStore, 22 | ) { 23 | // setting up disposers 24 | _setupDisposers(); 25 | 26 | // checking if user is logged in 27 | _isLoggedInUseCase.call(params: null).then((value) async { 28 | isLoggedIn = value; 29 | }); 30 | } 31 | 32 | // use cases:----------------------------------------------------------------- 33 | final IsLoggedInUseCase _isLoggedInUseCase; 34 | final SaveLoginStatusUseCase _saveLoginStatusUseCase; 35 | final LoginUseCase _loginUseCase; 36 | 37 | // stores:-------------------------------------------------------------------- 38 | // for handling form errors 39 | final FormErrorStore formErrorStore; 40 | 41 | // store for handling error messages 42 | final ErrorStore errorStore; 43 | 44 | // disposers:----------------------------------------------------------------- 45 | late List _disposers; 46 | 47 | void _setupDisposers() { 48 | _disposers = [ 49 | reaction((_) => success, (_) => success = false, delay: 200), 50 | ]; 51 | } 52 | 53 | // empty responses:----------------------------------------------------------- 54 | static ObservableFuture emptyLoginResponse = 55 | ObservableFuture.value(null); 56 | 57 | // store variables:----------------------------------------------------------- 58 | bool isLoggedIn = false; 59 | 60 | @observable 61 | bool success = false; 62 | 63 | @observable 64 | ObservableFuture loginFuture = emptyLoginResponse; 65 | 66 | @computed 67 | bool get isLoading => loginFuture.status == FutureStatus.pending; 68 | 69 | // actions:------------------------------------------------------------------- 70 | @action 71 | Future login(String email, String password) async { 72 | final LoginParams loginParams = 73 | LoginParams(username: email, password: password); 74 | final future = _loginUseCase.call(params: loginParams); 75 | loginFuture = ObservableFuture(future); 76 | 77 | await future.then((value) async { 78 | if (value != null) { 79 | await _saveLoginStatusUseCase.call(params: true); 80 | this.isLoggedIn = true; 81 | this.success = true; 82 | } 83 | }).catchError((e) { 84 | print(e); 85 | this.isLoggedIn = false; 86 | this.success = false; 87 | throw e; 88 | }); 89 | } 90 | 91 | logout() async { 92 | this.isLoggedIn = false; 93 | await _saveLoginStatusUseCase.call(params: false); 94 | } 95 | 96 | // general methods:----------------------------------------------------------- 97 | void dispose() { 98 | for (final d in _disposers) { 99 | d(); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /lib/presentation/login/store/login_store.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'login_store.dart'; 4 | 5 | // ************************************************************************** 6 | // StoreGenerator 7 | // ************************************************************************** 8 | 9 | // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic, no_leading_underscores_for_local_identifiers 10 | 11 | mixin _$UserStore on _UserStore, Store { 12 | Computed? _$isLoadingComputed; 13 | 14 | @override 15 | bool get isLoading => (_$isLoadingComputed ??= 16 | Computed(() => super.isLoading, name: '_UserStore.isLoading')) 17 | .value; 18 | 19 | late final _$successAtom = Atom(name: '_UserStore.success', context: context); 20 | 21 | @override 22 | bool get success { 23 | _$successAtom.reportRead(); 24 | return super.success; 25 | } 26 | 27 | @override 28 | set success(bool value) { 29 | _$successAtom.reportWrite(value, super.success, () { 30 | super.success = value; 31 | }); 32 | } 33 | 34 | late final _$loginFutureAtom = 35 | Atom(name: '_UserStore.loginFuture', context: context); 36 | 37 | @override 38 | ObservableFuture get loginFuture { 39 | _$loginFutureAtom.reportRead(); 40 | return super.loginFuture; 41 | } 42 | 43 | @override 44 | set loginFuture(ObservableFuture value) { 45 | _$loginFutureAtom.reportWrite(value, super.loginFuture, () { 46 | super.loginFuture = value; 47 | }); 48 | } 49 | 50 | late final _$loginAsyncAction = 51 | AsyncAction('_UserStore.login', context: context); 52 | 53 | @override 54 | Future login(String email, String password) { 55 | return _$loginAsyncAction.run(() => super.login(email, password)); 56 | } 57 | 58 | @override 59 | String toString() { 60 | return ''' 61 | success: ${success}, 62 | loginFuture: ${loginFuture}, 63 | isLoading: ${isLoading} 64 | '''; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/presentation/my_app.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/constants/app_theme.dart'; 2 | import 'package:boilerplate/constants/strings.dart'; 3 | import 'package:boilerplate/presentation/home/home.dart'; 4 | import 'package:boilerplate/presentation/home/store/language/language_store.dart'; 5 | import 'package:boilerplate/presentation/home/store/theme/theme_store.dart'; 6 | import 'package:boilerplate/presentation/login/login.dart'; 7 | import 'package:boilerplate/presentation/login/store/login_store.dart'; 8 | import 'package:boilerplate/utils/locale/app_localization.dart'; 9 | import 'package:boilerplate/utils/routes/routes.dart'; 10 | import 'package:flutter/material.dart'; 11 | import 'package:flutter_localizations/flutter_localizations.dart'; 12 | import 'package:flutter_mobx/flutter_mobx.dart'; 13 | 14 | import '../di/service_locator.dart'; 15 | 16 | class MyApp extends StatelessWidget { 17 | // This widget is the root of your application. 18 | // Create your store as a final variable in a base Widget. This works better 19 | // with Hot Reload than creating it directly in the `build` function. 20 | final ThemeStore _themeStore = getIt(); 21 | final LanguageStore _languageStore = getIt(); 22 | final UserStore _userStore = getIt(); 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | return Observer( 27 | builder: (context) { 28 | return MaterialApp( 29 | debugShowCheckedModeBanner: false, 30 | title: Strings.appName, 31 | theme: _themeStore.darkMode 32 | ? AppThemeData.darkThemeData 33 | : AppThemeData.lightThemeData, 34 | routes: Routes.routes, 35 | locale: Locale(_languageStore.locale), 36 | supportedLocales: _languageStore.supportedLanguages 37 | .map((language) => Locale(language.locale, language.code)) 38 | .toList(), 39 | localizationsDelegates: [ 40 | // A class which loads the translations from JSON files 41 | AppLocalizations.delegate, 42 | // Built-in localization of basic text for Material widgets 43 | GlobalMaterialLocalizations.delegate, 44 | // Built-in localization for text direction LTR/RTL 45 | GlobalWidgetsLocalizations.delegate, 46 | // Built-in localization of basic text for Cupertino widgets 47 | GlobalCupertinoLocalizations.delegate, 48 | ], 49 | home: _userStore.isLoggedIn ? HomeScreen() : LoginScreen(), 50 | ); 51 | }, 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/presentation/post/post_list.dart: -------------------------------------------------------------------------------- 1 | import 'package:another_flushbar/flushbar_helper.dart'; 2 | import 'package:boilerplate/core/widgets/progress_indicator_widget.dart'; 3 | import 'package:boilerplate/di/service_locator.dart'; 4 | import 'package:boilerplate/presentation/post/store/post_store.dart'; 5 | import 'package:boilerplate/utils/locale/app_localization.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:flutter_mobx/flutter_mobx.dart'; 8 | 9 | class PostListScreen extends StatefulWidget { 10 | @override 11 | _PostListScreenState createState() => _PostListScreenState(); 12 | } 13 | 14 | class _PostListScreenState extends State { 15 | //stores:--------------------------------------------------------------------- 16 | final PostStore _postStore = getIt(); 17 | 18 | @override 19 | void didChangeDependencies() { 20 | super.didChangeDependencies(); 21 | 22 | // check to see if already called api 23 | if (!_postStore.loading) { 24 | _postStore.getPosts(); 25 | } 26 | } 27 | 28 | @override 29 | Widget build(BuildContext context) { 30 | return _buildBody(); 31 | } 32 | 33 | // body methods:-------------------------------------------------------------- 34 | Widget _buildBody() { 35 | return Stack( 36 | children: [ 37 | _handleErrorMessage(), 38 | _buildMainContent(), 39 | ], 40 | ); 41 | } 42 | 43 | Widget _buildMainContent() { 44 | return Observer( 45 | builder: (context) { 46 | return _postStore.loading 47 | ? CustomProgressIndicatorWidget() 48 | : _buildListView(); 49 | }, 50 | ); 51 | } 52 | 53 | Widget _buildListView() { 54 | return _postStore.postList != null 55 | ? ListView.separated( 56 | itemCount: _postStore.postList!.posts!.length, 57 | separatorBuilder: (context, position) { 58 | return Divider(); 59 | }, 60 | itemBuilder: (context, position) { 61 | return _buildListItem(position); 62 | }, 63 | ) 64 | : Center( 65 | child: Text( 66 | AppLocalizations.of(context).translate('home_tv_no_post_found'), 67 | ), 68 | ); 69 | } 70 | 71 | Widget _buildListItem(int position) { 72 | return ListTile( 73 | dense: true, 74 | leading: Icon(Icons.cloud_circle), 75 | title: Text( 76 | '${_postStore.postList?.posts?[position].title}', 77 | maxLines: 1, 78 | overflow: TextOverflow.ellipsis, 79 | softWrap: false, 80 | style: Theme.of(context).textTheme.titleMedium, 81 | ), 82 | subtitle: Text( 83 | '${_postStore.postList?.posts?[position].body}', 84 | maxLines: 1, 85 | overflow: TextOverflow.ellipsis, 86 | softWrap: false, 87 | ), 88 | ); 89 | } 90 | 91 | Widget _handleErrorMessage() { 92 | return Observer( 93 | builder: (context) { 94 | if (_postStore.errorStore.errorMessage.isNotEmpty) { 95 | return _showErrorMessage(_postStore.errorStore.errorMessage); 96 | } 97 | 98 | return SizedBox.shrink(); 99 | }, 100 | ); 101 | } 102 | 103 | // General Methods:----------------------------------------------------------- 104 | _showErrorMessage(String message) { 105 | Future.delayed(Duration(milliseconds: 0), () { 106 | if (message.isNotEmpty) { 107 | FlushbarHelper.createError( 108 | message: message, 109 | title: AppLocalizations.of(context).translate('home_tv_error'), 110 | duration: Duration(seconds: 3), 111 | )..show(context); 112 | } 113 | }); 114 | 115 | return SizedBox.shrink(); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /lib/presentation/post/store/post_store.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/core/stores/error/error_store.dart'; 2 | import 'package:boilerplate/domain/entity/post/post_list.dart'; 3 | import 'package:boilerplate/utils/dio/dio_error_util.dart'; 4 | import 'package:mobx/mobx.dart'; 5 | 6 | import '../../../domain/usecase/post/get_post_usecase.dart'; 7 | 8 | part 'post_store.g.dart'; 9 | 10 | class PostStore = _PostStore with _$PostStore; 11 | 12 | abstract class _PostStore with Store { 13 | // constructor:--------------------------------------------------------------- 14 | _PostStore(this._getPostUseCase, this.errorStore); 15 | 16 | // use cases:----------------------------------------------------------------- 17 | final GetPostUseCase _getPostUseCase; 18 | 19 | // stores:-------------------------------------------------------------------- 20 | // store for handling errors 21 | final ErrorStore errorStore; 22 | 23 | // store variables:----------------------------------------------------------- 24 | static ObservableFuture emptyPostResponse = 25 | ObservableFuture.value(null); 26 | 27 | @observable 28 | ObservableFuture fetchPostsFuture = 29 | ObservableFuture(emptyPostResponse); 30 | 31 | @observable 32 | PostList? postList; 33 | 34 | @observable 35 | bool success = false; 36 | 37 | @computed 38 | bool get loading => fetchPostsFuture.status == FutureStatus.pending; 39 | 40 | // actions:------------------------------------------------------------------- 41 | @action 42 | Future getPosts() async { 43 | final future = _getPostUseCase.call(params: null); 44 | fetchPostsFuture = ObservableFuture(future); 45 | 46 | future.then((postList) { 47 | this.postList = postList; 48 | }).catchError((error) { 49 | errorStore.errorMessage = DioExceptionUtil.handleError(error); 50 | }); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lib/presentation/post/store/post_store.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'post_store.dart'; 4 | 5 | // ************************************************************************** 6 | // StoreGenerator 7 | // ************************************************************************** 8 | 9 | // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic, no_leading_underscores_for_local_identifiers 10 | 11 | mixin _$PostStore on _PostStore, Store { 12 | Computed? _$loadingComputed; 13 | 14 | @override 15 | bool get loading => (_$loadingComputed ??= 16 | Computed(() => super.loading, name: '_PostStore.loading')) 17 | .value; 18 | 19 | late final _$fetchPostsFutureAtom = 20 | Atom(name: '_PostStore.fetchPostsFuture', context: context); 21 | 22 | @override 23 | ObservableFuture get fetchPostsFuture { 24 | _$fetchPostsFutureAtom.reportRead(); 25 | return super.fetchPostsFuture; 26 | } 27 | 28 | @override 29 | set fetchPostsFuture(ObservableFuture value) { 30 | _$fetchPostsFutureAtom.reportWrite(value, super.fetchPostsFuture, () { 31 | super.fetchPostsFuture = value; 32 | }); 33 | } 34 | 35 | late final _$postListAtom = 36 | Atom(name: '_PostStore.postList', context: context); 37 | 38 | @override 39 | PostList? get postList { 40 | _$postListAtom.reportRead(); 41 | return super.postList; 42 | } 43 | 44 | @override 45 | set postList(PostList? value) { 46 | _$postListAtom.reportWrite(value, super.postList, () { 47 | super.postList = value; 48 | }); 49 | } 50 | 51 | late final _$successAtom = Atom(name: '_PostStore.success', context: context); 52 | 53 | @override 54 | bool get success { 55 | _$successAtom.reportRead(); 56 | return super.success; 57 | } 58 | 59 | @override 60 | set success(bool value) { 61 | _$successAtom.reportWrite(value, super.success, () { 62 | super.success = value; 63 | }); 64 | } 65 | 66 | late final _$getPostsAsyncAction = 67 | AsyncAction('_PostStore.getPosts', context: context); 68 | 69 | @override 70 | Future getPosts() { 71 | return _$getPostsAsyncAction.run(() => super.getPosts()); 72 | } 73 | 74 | @override 75 | String toString() { 76 | return ''' 77 | fetchPostsFuture: ${fetchPostsFuture}, 78 | postList: ${postList}, 79 | success: ${success}, 80 | loading: ${loading} 81 | '''; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /lib/utils/device/device_utils.dart: -------------------------------------------------------------------------------- 1 | // 2 | import 'package:flutter/material.dart'; 3 | 4 | /// Helper class for device related operations. 5 | /// 6 | class DeviceUtils { 7 | 8 | /// 9 | /// hides the keyboard if its already open 10 | /// 11 | static hideKeyboard(BuildContext context) { 12 | FocusScope.of(context).unfocus(); 13 | } 14 | 15 | /// 16 | /// accepts a double [scale] and returns scaled sized based on the screen 17 | /// orientation 18 | /// 19 | static double getScaledSize(BuildContext context, double scale) => 20 | scale * 21 | (MediaQuery.of(context).orientation == Orientation.portrait 22 | ? MediaQuery.of(context).size.width 23 | : MediaQuery.of(context).size.height); 24 | 25 | /// 26 | /// accepts a double [scale] and returns scaled sized based on the screen 27 | /// width 28 | /// 29 | static double getScaledWidth(BuildContext context, double scale) => 30 | scale * MediaQuery.of(context).size.width; 31 | 32 | /// 33 | /// accepts a double [scale] and returns scaled sized based on the screen 34 | /// height 35 | /// 36 | static double getScaledHeight(BuildContext context, double scale) => 37 | scale * MediaQuery.of(context).size.height; 38 | } -------------------------------------------------------------------------------- /lib/utils/dio/dio_error_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | class DioExceptionUtil { 4 | // general methods:----------------------------------------------------------- 5 | static String handleError(DioException error) { 6 | String errorDescription = ""; 7 | if (error is DioException) { 8 | switch (error.type) { 9 | case DioExceptionType.cancel: 10 | errorDescription = "Request to API server was cancelled"; 11 | break; 12 | case DioExceptionType.connectionError: 13 | case DioExceptionType.connectionTimeout: 14 | case DioExceptionType.unknown: 15 | errorDescription = "Connection timeout with API server"; 16 | break; 17 | case DioExceptionType.receiveTimeout: 18 | errorDescription = "Receive timeout in connection with API server"; 19 | break; 20 | case DioExceptionType.badResponse: 21 | errorDescription = 22 | "Received invalid status code: ${error.response?.statusCode}"; 23 | break; 24 | case DioExceptionType.sendTimeout: 25 | errorDescription = "Send timeout in connection with API server"; 26 | break; 27 | case DioExceptionType.badCertificate: 28 | errorDescription = "Incorrect certificate"; 29 | break; 30 | } 31 | } else { 32 | errorDescription = "Unexpected error occurred"; 33 | } 34 | return errorDescription; 35 | } 36 | } -------------------------------------------------------------------------------- /lib/utils/locale/app_localization.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:convert'; 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter/services.dart'; 6 | 7 | class AppLocalizations { 8 | // localization variables 9 | final Locale locale; 10 | late Map localizedStrings; 11 | 12 | // Static member to have a simple access to the delegate from the MaterialApp 13 | static const LocalizationsDelegate delegate = 14 | _AppLocalizationsDelegate(); 15 | 16 | // constructor 17 | AppLocalizations(this.locale); 18 | 19 | // Helper method to keep the code in the widgets concise 20 | // Localizations are accessed using an InheritedWidget "of" syntax 21 | static AppLocalizations of(BuildContext context) { 22 | return Localizations.of(context, AppLocalizations)!; 23 | } 24 | 25 | // This is a helper method that will load local specific strings from file 26 | // present in lang folder 27 | Future load() async { 28 | // Load the language JSON file from the "lang" folder 29 | String jsonString = 30 | await rootBundle.loadString('assets/lang/${locale.languageCode}.json'); 31 | Map jsonMap = json.decode(jsonString); 32 | 33 | localizedStrings = jsonMap.map((key, value) { 34 | return MapEntry( 35 | key, value.toString().replaceAll(r"\'", "'").replaceAll(r"\t", " ")); 36 | }); 37 | 38 | return true; 39 | } 40 | 41 | // This method will be called from every widget which needs a localized text 42 | String translate(String key) { 43 | return localizedStrings[key]!; 44 | } 45 | } 46 | 47 | // LocalizationsDelegate is a factory for a set of localized resources 48 | // In this case, the localized strings will be gotten in an AppLocalizations object 49 | class _AppLocalizationsDelegate 50 | extends LocalizationsDelegate { 51 | // ignore: non_constant_identifier_names 52 | final String TAG = "AppLocalizations"; 53 | 54 | // This delegate instance will never change (it doesn't even have fields!) 55 | // It can provide a constant constructor. 56 | const _AppLocalizationsDelegate(); 57 | 58 | @override 59 | bool isSupported(Locale locale) { 60 | // Include all of your supported language codes here 61 | return ['en', 'es', 'da'].contains(locale.languageCode); 62 | } 63 | 64 | @override 65 | Future load(Locale locale) async { 66 | // AppLocalizations class is where the JSON loading actually runs 67 | AppLocalizations localizations = new AppLocalizations(locale); 68 | await localizations.load(); 69 | return localizations; 70 | } 71 | 72 | @override 73 | bool shouldReload(_AppLocalizationsDelegate old) => false; 74 | } 75 | -------------------------------------------------------------------------------- /lib/utils/routes/routes.dart: -------------------------------------------------------------------------------- 1 | import 'package:boilerplate/presentation/home/home.dart'; 2 | import 'package:boilerplate/presentation/login/login.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class Routes { 6 | Routes._(); 7 | 8 | //static variables 9 | static const String splash = '/splash'; 10 | static const String login = '/login'; 11 | static const String home = '/post'; 12 | 13 | static final routes = { 14 | login: (BuildContext context) => LoginScreen(), 15 | home: (BuildContext context) => HomeScreen(), 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /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 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /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 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /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, "flutter_boilerplate_project"); 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, "flutter_boilerplate_project"); 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 path_provider_foundation 9 | import shared_preferences_foundation 10 | 11 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 12 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 13 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 14 | } 15 | -------------------------------------------------------------------------------- /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 | target 'RunnerTests' do 35 | inherit! :search_paths 36 | end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_macos_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /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 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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 = flutter_boilerplate_project 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.iotecksolutions.flutterBoilerplateProject 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.iotecksolutions. 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/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() 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/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: boilerplate 2 | description: A flutter boilerplate project created using MobX and Provider. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # Read more about versioning at semver.org. 10 | version: 1.0.0+1 11 | 12 | environment: 13 | sdk: '>=3.0.6 <4.0.0' 14 | 15 | dependencies: 16 | flutter: 17 | sdk: flutter 18 | 19 | flutter_localizations: 20 | sdk: flutter 21 | 22 | # A 23 | another_flushbar: ^1.12.29 24 | # B 25 | # C 26 | cupertino_icons: ^1.0.5 27 | # D 28 | dio: ^5.1.1 29 | # E 30 | event_bus: ^2.0.0 31 | # F 32 | flutter_mobx: ^2.0.6+5 33 | # G 34 | get_it: ^7.2.0 35 | google_fonts: ^4.0.3 36 | # H 37 | http: ^0.13.5 38 | # I 39 | intl: ^0.19.0 40 | # J 41 | json_serializable: ^6.6.1 42 | # K 43 | # L 44 | # M 45 | mobx: ^2.1.4 46 | # N 47 | # O 48 | # P 49 | path_provider: ^2.0.14 50 | # Q 51 | # R 52 | # S 53 | shared_preferences: ^2.1.0 54 | sembast_web: ^2.1.3 55 | sembast: ^3.4.4 56 | # T 57 | # U 58 | # V 59 | validators: ^3.0.0 60 | # W 61 | # X 62 | xxtea: ^2.1.0 63 | # Y 64 | # Z 65 | 66 | dev_dependencies: 67 | flutter_test: 68 | sdk: flutter 69 | 70 | # The following adds the launcher icon support to your application. 71 | # run below mentioned commands to generate launcher icons 72 | # flutter packages get 73 | # flutter packages pub run flutter_launcher_icons:main 74 | flutter_launcher_icons: ^0.13.1 75 | mobx_codegen: ^2.2.0 76 | build_runner: ^2.3.3 77 | analyzer: ^5.10.0 78 | 79 | flutter_icons: 80 | image_path: "assets/icons/ic_launcher.png" 81 | android: true 82 | ios: true 83 | 84 | flutter: 85 | uses-material-design: true 86 | assets: 87 | - assets/images/ 88 | - assets/icons/ 89 | - assets/lang/ 90 | 91 | fonts: 92 | - family: ProductSans 93 | fonts: 94 | - asset: assets/fonts/Product-Sans-Regular.ttf 95 | - asset: assets/fonts/Product-Sans-Italic.ttf 96 | style: italic 97 | - asset: assets/fonts/Product-Sans-Bold.ttf 98 | weight: 700 99 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:boilerplate/presentation/my_app.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | 12 | void main() { 13 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 14 | // Build our app and trigger a frame. 15 | await tester.pumpWidget(MyApp()); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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 | flutter_boilerplate_project 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_boilerplate_project", 3 | "short_name": "flutter_boilerplate_project", 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(flutter_boilerplate_project 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 "flutter_boilerplate_project") 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 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Fully re-copy the assets directory on each build to avoid having stale files 91 | # from a previous install. 92 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 93 | install(CODE " 94 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 95 | " COMPONENT Runtime) 96 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 97 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 98 | 99 | # Install the AOT library on non-Debug builds only. 100 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 101 | CONFIGURATIONS Profile;Release 102 | COMPONENT Runtime) 103 | -------------------------------------------------------------------------------- /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 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /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 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.iotecksolutions" "\0" 93 | VALUE "FileDescription", "flutter_boilerplate_project" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "flutter_boilerplate_project" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.iotecksolutions. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "flutter_boilerplate_project.exe" "\0" 98 | VALUE "ProductName", "flutter_boilerplate_project" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | return true; 35 | } 36 | 37 | void FlutterWindow::OnDestroy() { 38 | if (flutter_controller_) { 39 | flutter_controller_ = nullptr; 40 | } 41 | 42 | Win32Window::OnDestroy(); 43 | } 44 | 45 | LRESULT 46 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 47 | WPARAM const wparam, 48 | LPARAM const lparam) noexcept { 49 | // Give Flutter, including plugins, an opportunity to handle window messages. 50 | if (flutter_controller_) { 51 | std::optional result = 52 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 53 | lparam); 54 | if (result) { 55 | return *result; 56 | } 57 | } 58 | 59 | switch (message) { 60 | case WM_FONTCHANGE: 61 | flutter_controller_->engine()->ReloadSystemFonts(); 62 | break; 63 | } 64 | 65 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 66 | } 67 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"flutter_boilerplate_project", 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/zubairehman/flutter_boilerplate_project/70657cd1e72b5ae471e417401b056253ac65d07f/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 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /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 a win32 window with |title| that is positioned and sized 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 this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | --------------------------------------------------------------------------------