├── .DS_Store ├── .crashlytics └── dump_syms.bin ├── .gitattributes ├── .gitignore ├── .idea ├── libraries │ ├── Dart_SDK.xml │ └── KotlinJavaRuntime.xml ├── modules.xml ├── runConfigurations │ └── main_dart.xml └── workspace.xml ├── .metadata ├── .vscode └── settings.json ├── README.md ├── analysis_options.yaml ├── android ├── .DS_Store ├── .gitignore ├── app │ ├── .DS_Store │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── efestech │ │ │ │ └── tutorial_app │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── tutorial_app_android.iml ├── assets ├── test.json ├── test │ └── test.json └── translations │ └── en-US.json ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Podfile.lock ├── 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 ├── feature │ ├── auth │ │ ├── auth_splash │ │ │ └── view │ │ │ │ └── auth_splash_view.dart │ │ ├── login │ │ │ ├── model │ │ │ │ ├── login_request_model.dart │ │ │ │ └── login_response_model.dart │ │ │ ├── view │ │ │ │ ├── login_view.dart │ │ │ │ └── src │ │ │ │ │ ├── _email_field.dart │ │ │ │ │ ├── _error_field.dart │ │ │ │ │ ├── _login_button.dart │ │ │ │ │ ├── _password_field.dart │ │ │ │ │ └── login_view_mixin.dart │ │ │ └── view_model │ │ │ │ └── login_view_model.dart │ │ └── register │ │ │ ├── model │ │ │ ├── register_reponse_model.dart │ │ │ └── register_request_model.dart │ │ │ ├── view │ │ │ ├── register_view.dart │ │ │ └── src │ │ │ │ ├── _button_field.dart │ │ │ │ ├── _confirm_password_field.dart │ │ │ │ ├── _email_field.dart │ │ │ │ ├── _error_field.dart │ │ │ │ ├── _full_name_field.dart │ │ │ │ ├── _password_field.dart │ │ │ │ ├── _phone_field.dart │ │ │ │ └── register_view_mixin.dart │ │ │ └── view_model │ │ │ └── register_view_model.dart │ ├── home │ │ ├── model │ │ │ ├── address.dart │ │ │ ├── address.g.dart │ │ │ ├── company.dart │ │ │ ├── company.g.dart │ │ │ ├── geo.dart │ │ │ ├── geo.g.dart │ │ │ ├── user_model.dart │ │ │ ├── user_model.g.dart │ │ │ ├── user_response.dart │ │ │ └── user_response_model.dart │ │ ├── service │ │ │ └── home_service.dart │ │ ├── view │ │ │ ├── home_view.dart │ │ │ ├── src │ │ │ │ └── _list_view_builder.dart │ │ │ └── user_detail_view.dart │ │ └── view_model │ │ │ └── home_view_model.dart │ ├── photos │ │ ├── model │ │ │ ├── photo_response.dart │ │ │ ├── photo_response.g.dart │ │ │ ├── photos.dart │ │ │ ├── photos.g.dart │ │ │ └── photos_response_model.dart │ │ ├── service │ │ │ └── photos_service.dart │ │ ├── view │ │ │ ├── photos_view.dart │ │ │ └── src │ │ │ │ └── _photos_gridview_builder.dart │ │ └── view_model │ │ │ └── ptohos_view_model.dart │ ├── profile │ │ ├── model │ │ │ ├── profile_model.dart │ │ │ └── profile_model.g.dart │ │ ├── view │ │ │ ├── profile_view.dart │ │ │ └── profile_view_mixin.dart │ │ └── view_model │ │ │ └── profile_view_model.dart │ ├── splash │ │ └── view │ │ │ └── splash_view.dart │ └── test_page │ │ ├── model │ │ └── comments_model.dart │ │ ├── view │ │ └── test_view.dart │ │ └── view_model │ │ └── test_view_model.dart ├── info.md ├── main.dart └── product │ ├── .DS_Store │ ├── core │ ├── constants │ │ └── remote_config_keys.dart │ ├── enums │ │ ├── firebase_status.dart │ │ └── shared_manager_enums.dart │ ├── model │ │ ├── base_model.dart │ │ ├── base_response_model.dart │ │ ├── firestore_model.dart │ │ └── response_model.dart │ ├── service │ │ ├── dio_service_manager.dart │ │ ├── firebase_service.dart │ │ ├── iservice_manager.dart │ │ └── service_manager.dart │ └── starter │ │ └── starter.dart │ ├── utils │ ├── .DS_Store │ ├── cache │ │ ├── cache_manager.dart │ │ ├── mixin │ │ │ ├── cache_auth_mixin.dart │ │ │ ├── cache_models_mixin.dart │ │ │ └── cache_repository_mixin.dart │ │ └── preference_key.dart │ ├── getit │ │ ├── product_state_container.dart │ │ └── product_state_items.dart │ ├── localization │ │ ├── locale_keys.g.dart │ │ └── localization_manager.dart │ ├── remote_config │ │ └── remote_config_manager.dart │ ├── router │ │ ├── adaptive_page_builder.dart │ │ ├── route_params.dart │ │ ├── route_paths.dart │ │ └── router_manager.dart │ ├── shared │ │ └── shared_manager.dart │ ├── snackbar │ │ └── custom_snackbar.dart │ └── theme │ │ ├── color_schemes.g.dart │ │ └── theme.dart │ └── widgets │ ├── maps │ ├── _apple_maps_widget.dart │ ├── _google_maps_widget.dart │ └── maps_view.dart │ ├── shimmer │ ├── custom_image_shimmer.dart │ └── custom_list_shimmer.dart │ ├── text │ └── custom_text.dart │ └── text_field │ └── custom_text_field.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 ├── Podfile.lock ├── 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 ├── service │ └── service_test.dart ├── utils │ └── snackbar_test.dart ├── widget_test.dart └── widgets │ ├── custom_text_field_test.dart │ ├── custom_text_test.dart │ ├── profile_view_test.dart │ └── splash_view_test.dart ├── tutorial_app.iml ├── 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 /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/.DS_Store -------------------------------------------------------------------------------- /.crashlytics/dump_syms.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/.crashlytics/dump_syms.bin -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://www.dartlang.org/guides/libraries/private-files 2 | 3 | # Files and directories created by pub 4 | .dart_tool/ 5 | .packages 6 | build/ 7 | # If you're building an application, you may want to check-in your pubspec.lock 8 | pubspec.lock 9 | 10 | # Directory created by dartdoc 11 | # If you don't generate documentation locally you can remove this line. 12 | doc/api/ 13 | 14 | # dotenv environment variables file 15 | .env* 16 | 17 | # Avoid committing generated Javascript files: 18 | *.dart.js 19 | *.info.json # Produced by the --dump-info flag. 20 | *.js # When generated by dart2js. Don't specify *.js if your 21 | # project includes source files written in JavaScript. 22 | *.js_ 23 | *.js.deps 24 | *.js.map 25 | 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | GoogleService-Info.plist 29 | google-services.json 30 | firebase_options.dart 31 | firebase_app_id_file.json -------------------------------------------------------------------------------- /.idea/libraries/Dart_SDK.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/libraries/KotlinJavaRuntime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations/main_dart.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 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 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /.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 and should not be manually edited. 5 | 6 | version: 7 | revision: "44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2" 8 | channel: "master" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 17 | base_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 18 | - platform: android 19 | create_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 20 | base_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 21 | - platform: ios 22 | create_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 23 | base_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 24 | - platform: linux 25 | create_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 26 | base_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 27 | - platform: macos 28 | create_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 29 | base_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 30 | - platform: web 31 | create_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 32 | base_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 33 | - platform: windows 34 | create_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 35 | base_revision: 44e440ae9ddeb4714bbe73d4326b3ae0ddb1dce2 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 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cmake.configureOnOpen": false 3 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Bu repo Flutter'a yeni başlayanlar için bir örnek oluşturması için yapılmış bir uygulamadır. 2 | Sorularınızı ve yetersiz açıklama olduğunu düşündüğünüz ve daha fazla detay istediğiniz yerleri Issue oluşturarak belirtebilirsiniz. 3 | 4 | Bu repo sürekli güncellenerek güncel tutulacaktır. Gerçek bir projede kullanım senaryoları eklenecektir. 5 | 6 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | analyzer: 11 | enable-experiment: 12 | - macros 13 | include: package:flutter_lints/flutter.yaml 14 | 15 | 16 | linter: 17 | rules: 18 | constant_identifier_names: false -------------------------------------------------------------------------------- /android/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/android/.DS_Store -------------------------------------------------------------------------------- /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/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/android/app/.DS_Store -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id "dev.flutter.flutter-gradle-plugin" 6 | } 7 | 8 | def localProperties = new Properties() 9 | def localPropertiesFile = rootProject.file("local.properties") 10 | if (localPropertiesFile.exists()) { 11 | localPropertiesFile.withReader("UTF-8") { reader -> 12 | localProperties.load(reader) 13 | } 14 | } 15 | 16 | def flutterVersionCode = localProperties.getProperty("flutter.versionCode") 17 | if (flutterVersionCode == null) { 18 | flutterVersionCode = "1" 19 | } 20 | 21 | def flutterVersionName = localProperties.getProperty("flutter.versionName") 22 | if (flutterVersionName == null) { 23 | flutterVersionName = "1.0" 24 | } 25 | 26 | android { 27 | 28 | compileSdk = 34 29 | ndkVersion = flutter.ndkVersion 30 | 31 | compileOptions { 32 | sourceCompatibility = JavaVersion.VERSION_1_8 33 | targetCompatibility = JavaVersion.VERSION_1_8 34 | } 35 | 36 | defaultConfig { 37 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 38 | applicationId = "com.efestech.tutorial_app" 39 | // You can update the following values to match your application needs. 40 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 41 | minSdk = 23 42 | targetSdk = flutter.targetSdkVersion 43 | versionCode = flutterVersionCode.toInteger() 44 | versionName = flutterVersionName 45 | } 46 | 47 | buildTypes { 48 | release { 49 | // TODO: Add your own signing config for the release build. 50 | // Signing with the debug keys for now, so `flutter run --release` works. 51 | signingConfig = signingConfigs.debug 52 | } 53 | } 54 | namespace = "com.efestech.tutorial_app" 55 | } 56 | 57 | flutter { 58 | source = "../.." 59 | } 60 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/efestech/tutorial_app/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.efestech.tutorial_app 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() 6 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | 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 | org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version "7.3.0" apply false 22 | id "org.jetbrains.kotlin.android" version "1.9.20" apply false 23 | } 24 | 25 | include ":app" 26 | -------------------------------------------------------------------------------- /android/tutorial_app_android.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /assets/test/test.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/assets/test/test.json -------------------------------------------------------------------------------- /assets/translations/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": { 3 | "title": "Tutorial App", 4 | "saved": "Saved", 5 | "notSaved": "Not saved", 6 | "updated": "Updated", 7 | "deleted": "Deleted", 8 | "loading": "Loading", 9 | "error": "Error", 10 | "noData": "No data", 11 | "noDataFound": "No data found" 12 | }, 13 | "userTexts": { 14 | "name": "Name", 15 | "username": "Username", 16 | "email": "Email", 17 | "password": "Password", 18 | "phone": "Phone", 19 | "address": "Address", 20 | "website": "Website", 21 | "company": "Company", 22 | "city": "City", 23 | "zipcode": "Zipcode", 24 | "geo": "Geo" 25 | }, 26 | "photos": { 27 | "title": "Photos" 28 | }, 29 | "buttons": { 30 | "submit": "Submit", 31 | "cancel": "Cancel", 32 | "edit": "Edit", 33 | "delete": "Delete", 34 | "add": "Add", 35 | "save": "Save", 36 | "close": "Close", 37 | "back": "Back", 38 | "next": "Next", 39 | "finish": "Finish" 40 | }, 41 | "args": { 42 | "name": "Name: {} {id}" 43 | }, 44 | "erroStatus": { 45 | "success": "Success {}", 46 | "userNotFound": "User not found", 47 | "weakPassword": "Weak password", 48 | "tooManyRequests": "Too many requests", 49 | "undefined": "Undefined", 50 | "wrongPassword": "Wrong password", 51 | "emailAlreadyInUse": "E-mail already in use", 52 | "invalidEmail": "Invalid e-mail", 53 | "userDisabled": "User disabled", 54 | "operationNotAllowed": "Operation not allowed", 55 | "invalidPassword": "Invalid password", 56 | "invalidArgument": "Invalid argument", 57 | "notFound": "Not found", 58 | "alreadyExists": "Already exists", 59 | "permissionDenied": "Permission denied", 60 | "unauthenticated": "Unauthenticated", 61 | "resourceExhausted": "Resource exhausted", 62 | "aborted": "Aborted", 63 | "outOfRange": "Out of range", 64 | "unimplemented": "Unimplemented", 65 | "internal": "Internal", 66 | "unavailable": "Unavailable", 67 | "dataLoss": "Data loss", 68 | "unknown": "Unknown", 69 | "verifyEmail": "Verify your e-mail", 70 | "invalidCredential": "Invalid User Credential" 71 | } 72 | } -------------------------------------------------------------------------------- /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 | 12.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? "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig" 3 | #include "Generated.xcconfig" 4 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | platform :ios, '14.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /ios/Runner.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.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 Flutter 2 | import UIKit 3 | import GoogleMaps 4 | 5 | @main 6 | @objc class AppDelegate: FlutterAppDelegate { 7 | override func application( 8 | _ application: UIApplication, 9 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 10 | ) -> Bool { 11 | /// Güvenlik nedeniyle IP adresi kısıtlaması yapıldı. 12 | /// Bu nedenle Google Maps API Key'i kısıtlıdır. 13 | /// Eğer uygulamayı çalıştırmak isterseniz, kendi API Key'inizi kullanmalısınız. 14 | /// API Key almak için: https://developers.google.com/maps/documentation/ios-sdk/get-api-key 15 | GMSServices.provideAPIKey("AIzaSyBDfOvDcHODZDGwkQqooDGNs1tjCHrtJYk") 16 | GeneratedPluginRegistrant.register(with: self) 17 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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 | Tutorial App 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | tutorial_app 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 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /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/feature/auth/auth_splash/view/auth_splash_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:firebase_auth/firebase_auth.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:tutorial_app/feature/auth/login/view/login_view.dart'; 4 | import 'package:tutorial_app/feature/profile/view/profile_view.dart'; 5 | import 'package:tutorial_app/product/utils/getit/product_state_items.dart'; 6 | 7 | class AuthSplashView extends StatelessWidget { 8 | const AuthSplashView({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | final cacheManager = ProductStateItems.cacheManager; 13 | final token = cacheManager.getToken(); 14 | return StreamBuilder( 15 | stream: FirebaseAuth.instance.authStateChanges(), 16 | builder: (context, snapshot) { 17 | if (snapshot.data != null) { 18 | return const ProfileView(); 19 | } else if (snapshot.connectionState == ConnectionState.waiting) { 20 | return const Center( 21 | child: CircularProgressIndicator.adaptive(), 22 | ); 23 | } 24 | return const LoginView(); 25 | }, 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/feature/auth/login/model/login_request_model.dart: -------------------------------------------------------------------------------- 1 | final class LoginRequestModel { 2 | final String? email; 3 | final String? password; 4 | 5 | LoginRequestModel({ 6 | this.email, 7 | this.password, 8 | }); 9 | 10 | factory LoginRequestModel.fromJson(Map json) { 11 | return LoginRequestModel( 12 | email: json['email'], 13 | password: json['password'], 14 | ); 15 | } 16 | 17 | Map toJson() { 18 | return { 19 | 'email': email, 20 | 'password': password, 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/feature/auth/login/model/login_response_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:firebase_auth/firebase_auth.dart'; 2 | 3 | final class LoginResponseModel { 4 | final UserCredential? user; 5 | final String? error; 6 | 7 | LoginResponseModel({ 8 | this.user, 9 | this.error, 10 | }); 11 | 12 | factory LoginResponseModel.fromJson(Map json) { 13 | return LoginResponseModel( 14 | user: json['user'], 15 | ); 16 | } 17 | 18 | Map toJson() { 19 | return { 20 | 'user': user, 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/feature/auth/login/view/src/_email_field.dart: -------------------------------------------------------------------------------- 1 | part of '../login_view.dart'; 2 | 3 | final class _EmailField extends StatelessWidget { 4 | const _EmailField({ 5 | required this.emailController, 6 | }); 7 | 8 | final TextEditingController emailController; 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return CustomTextField( 13 | name: 'email', 14 | controller: emailController, 15 | label: 'Email', 16 | validators: [ 17 | FormBuilderValidators.required(errorText: 'Email is required'), 18 | FormBuilderValidators.email(errorText: 'Please enter a valid email'), 19 | ], 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/feature/auth/login/view/src/_error_field.dart: -------------------------------------------------------------------------------- 1 | part of '../login_view.dart'; 2 | 3 | final class _ErrorField extends StatelessWidget { 4 | const _ErrorField(); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return Selector( 9 | selector: (context, model) => model.error ?? '', 10 | builder: (context, error, child) { 11 | return Text( 12 | error, 13 | ).tr(); 14 | }, 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/feature/auth/login/view/src/_login_button.dart: -------------------------------------------------------------------------------- 1 | part of '../login_view.dart'; 2 | 3 | final class _LoginButton extends StatelessWidget { 4 | const _LoginButton({ 5 | required this.formKey, 6 | required this.emailController, 7 | required this.passwordController, 8 | }); 9 | 10 | final GlobalKey formKey; 11 | final TextEditingController emailController; 12 | final TextEditingController passwordController; 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return ElevatedButton( 17 | onPressed: () { 18 | formKey.currentState?.save(); 19 | if (formKey.currentState?.validate() ?? false) { 20 | context.read().signInWithEmail( 21 | LoginRequestModel( 22 | email: emailController.text.trim(), 23 | password: passwordController.text.trim(), 24 | ), 25 | ); 26 | } 27 | }, 28 | child: CustomText(LocaleKeys.buttons_submit.tr()), 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/feature/auth/login/view/src/_password_field.dart: -------------------------------------------------------------------------------- 1 | part of '../login_view.dart'; 2 | 3 | final class _PasswordField extends StatelessWidget { 4 | const _PasswordField({ 5 | required this.passwordController, 6 | }); 7 | 8 | final TextEditingController passwordController; 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return CustomTextField( 13 | name: 'password', 14 | controller: passwordController, 15 | label: 'Password', 16 | obscureText: true, 17 | validators: [ 18 | FormBuilderValidators.required(errorText: 'Password is required'), 19 | FormBuilderValidators.minLength(6, 20 | errorText: 'Password must be at least 6 characters'), 21 | ], 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/feature/auth/login/view/src/login_view_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:firebase_remote_config/firebase_remote_config.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_form_builder/flutter_form_builder.dart'; 6 | import 'package:tutorial_app/feature/auth/login/view/login_view.dart'; 7 | import 'package:tutorial_app/feature/auth/login/view_model/login_view_model.dart'; 8 | 9 | import '../../../../../product/utils/remote_config/remote_config_manager.dart'; 10 | 11 | /// [LoginViewMixin] sınıfı [LoginView] sınıfı içerisinde kullanılan değişkenlerin 12 | /// ve fonksiyonların tekrar tekrar tanımlanmasını engellemek için oluşturulmuştur. 13 | /// Bu sayede kod tekrarı engellenmiş olur. 14 | /// Ayrıca [LoginView] sınıfının içerisindeki kodun okunabilirliği arttırılmış olur. 15 | /// [State] sınıfının tipi olarak [LoginView] sınıfı verilmiştir. 16 | /// Bu sayede bu mixin sınıfı sadece [LoginView] sınıfı ile kullanılabilir. 17 | mixin LoginViewMixin on State { 18 | late final GlobalKey formKey; 19 | late final TextEditingController emailController; 20 | late final TextEditingController passwordController; 21 | late final Stream streamSubscription; 22 | late final LoginViewModel loginViewModel; 23 | 24 | /// [initState] fonksiyonu [State] sınıfının bir metodu olup, bu sınıfın 25 | /// bir parçasıdır. Bu fonksiyon [State] sınıfı oluşturulduğunda çalıştırılır. 26 | /// Bu fonksiyon içerisinde [formKey], [emailController] ve [passwordController] 27 | /// değişkenlerine değer ataması yapılır. 28 | /// Bu sayede değişkenlerin değerleri bu sayfada oluşturulduğunda atanmış olur. 29 | /// Bunu yapmamızda ki amaç bu değişkenlerin değerlerinin sadece bu sayfa oluştuğunda 30 | /// atanmasını sağlamaktır. Bu sayede bu değişkenlerin kullanılmaması durumunda 31 | /// gereksiz bellek kullanımı engellenmiş olur. 32 | /// Bu fonksiyon içerisinde [super.initState()] fonksiyonu çağrılarak [State] sınıfının 33 | /// [initState] fonksiyonu çalıştırılır. 34 | /// Bu sayede [State] sınıfının [initState] fonksiyonu içerisindeki işlemler yapılır. 35 | /// Ve [State] sınıfının oluşturulması sağlanır. 36 | @override 37 | void initState() { 38 | formKey = GlobalKey(); 39 | emailController = TextEditingController(); 40 | passwordController = TextEditingController(); 41 | streamSubscription = RemoteConfigManager.onConfigChanged; 42 | loginViewModel = LoginViewModel(); 43 | super.initState(); 44 | } 45 | 46 | /// [dispose] fonksiyonu [State] sınıfının bir metodu olup, bu sınıfın 47 | /// bir parçasıdır. Bu fonksiyon [State] sınıfı silindiğinde çalıştırılır. 48 | /// Bu fonksiyon içerisinde [emailController], [passwordController] ve [formKey] 49 | /// değişkenlerinin bellekten temizlenmesi sağlanır. 50 | /// Bu sayede bu değişkenlerin gereksiz bellek kullanımı engellenmiş olur. 51 | /// Bu fonksiyon içerisinde [super.dispose()] fonksiyonu çağrılarak [State] sınıfının 52 | /// [dispose] fonksiyonu çalıştırılır. 53 | /// Bu sayede [State] sınıfının [dispose] fonksiyonu içerisindeki işlemler yapılır. 54 | /// Bu sayede [State] sınıfının bellekten temizlenmesi sağlanır. 55 | @override 56 | void dispose() { 57 | emailController.dispose(); 58 | passwordController.dispose(); 59 | formKey.currentState?.dispose(); 60 | super.dispose(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/feature/auth/login/view_model/login_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:firebase_auth/firebase_auth.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:tutorial_app/feature/auth/login/model/login_request_model.dart'; 4 | import 'package:tutorial_app/product/core/constants/remote_config_keys.dart'; 5 | import 'package:tutorial_app/product/utils/remote_config/remote_config_manager.dart'; 6 | import '../../../../product/core/service/firebase_service.dart'; 7 | import '../model/login_response_model.dart'; 8 | 9 | final class LoginViewModel extends ChangeNotifier { 10 | final FirebaseService _firebaseService = FirebaseService(); 11 | 12 | UserCredential? _userCredential; 13 | String _error = ''; 14 | String _remoteConfigValue = ''; 15 | 16 | UserCredential? get userCredential => _userCredential; 17 | String? get error => _error; 18 | String? get remoteConfigValue => _remoteConfigValue; 19 | 20 | Future signInWithEmail(LoginRequestModel model) async { 21 | if (model.email == null || model.password == null) { 22 | return; 23 | } 24 | final LoginResponseModel response = await _firebaseService.signInWithEmail( 25 | model, 26 | ); 27 | 28 | _userCredential = response.user; 29 | _error = response.error ?? ''; 30 | if (hasListeners) { 31 | notifyListeners(); 32 | } 33 | } 34 | 35 | /// [getRemoteConfig] metodu ile remote config'ten veri çekilir. 36 | /// Burada veri keyi sabit olarak verilmiştir çünkü metodun yapacağı işlem önceden bellidir. 37 | Future getRemoteConfig() async { 38 | RemoteConfigManager.fetchAndActivate(); 39 | final response = RemoteConfigManager.getString( 40 | RemoteConfigKeys.loginBackgroundImage, 41 | ); 42 | _remoteConfigValue = response; 43 | if (hasListeners) { 44 | notifyListeners(); 45 | } 46 | } 47 | 48 | void logout() { 49 | _userCredential = null; 50 | _error = ''; 51 | _remoteConfigValue = ''; 52 | if (!hasListeners) return; 53 | notifyListeners(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/feature/auth/register/model/register_reponse_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:firebase_auth/firebase_auth.dart'; 2 | 3 | final class RegisterResponseModel { 4 | final String? error; 5 | final UserCredential? user; 6 | 7 | RegisterResponseModel({ 8 | this.error, 9 | this.user, 10 | }); 11 | 12 | factory RegisterResponseModel.fromJson(Map json) { 13 | return RegisterResponseModel( 14 | user: json['user'], 15 | ); 16 | } 17 | 18 | Map toJson() { 19 | return { 20 | 'user': user, 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/feature/auth/register/model/register_request_model.dart: -------------------------------------------------------------------------------- 1 | final class RegisterRequestModel { 2 | final String? fullName; 3 | final String? email; 4 | final String? password; 5 | final String? phoneNumber; 6 | 7 | RegisterRequestModel({ 8 | this.email, 9 | this.password, 10 | this.fullName, 11 | this.phoneNumber, 12 | }); 13 | 14 | Map toJson() { 15 | return { 16 | 'email': email, 17 | 'password': password, 18 | 'fullName': fullName, 19 | 'phoneNumber': phoneNumber, 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/feature/auth/register/view/register_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_form_builder/flutter_form_builder.dart'; 3 | import 'package:form_builder_validators/form_builder_validators.dart'; 4 | import 'package:provider/provider.dart'; 5 | import 'package:tutorial_app/feature/auth/register/model/register_request_model.dart'; 6 | import 'package:tutorial_app/feature/auth/register/view_model/register_view_model.dart'; 7 | import 'package:tutorial_app/product/core/service/firebase_service.dart'; 8 | import 'package:tutorial_app/product/widgets/text_field/custom_text_field.dart'; 9 | 10 | part 'src/register_view_mixin.dart'; 11 | part 'src/_button_field.dart'; 12 | part 'src/_confirm_password_field.dart'; 13 | part 'src/_email_field.dart'; 14 | part 'src/_error_field.dart'; 15 | part 'src/_password_field.dart'; 16 | part 'src/_full_name_field.dart'; 17 | part 'src/_phone_field.dart'; 18 | 19 | class RegisterView extends StatefulWidget { 20 | const RegisterView({super.key}); 21 | 22 | @override 23 | State createState() => _RegisterViewState(); 24 | } 25 | 26 | class _RegisterViewState extends State with RegisterViewMixin { 27 | @override 28 | Widget build(BuildContext context) { 29 | return Scaffold( 30 | appBar: AppBar( 31 | title: const Text('Register'), 32 | ), 33 | body: ChangeNotifierProvider( 34 | create: (context) => registerViewModel, 35 | child: Center( 36 | child: SingleChildScrollView( 37 | padding: const EdgeInsets.all(8.0), 38 | child: FormBuilder( 39 | key: formKey, 40 | child: Column( 41 | children: [ 42 | const FlutterLogo(size: 150, style: FlutterLogoStyle.stacked), 43 | const SizedBox(height: 16.0), 44 | _FullNameField(emailController: fullNameController), 45 | const SizedBox(height: 16.0), 46 | _PhoneField(emailController: phoneController), 47 | const SizedBox(height: 16.0), 48 | _EmailField(emailController: emailController), 49 | const SizedBox(height: 16.0), 50 | _PasswordField(passwordController: passwordController), 51 | const SizedBox(height: 16.0), 52 | _ConfirmPasswordField( 53 | confirmPasswordController: confirmPasswordController, 54 | passwordController: passwordController, 55 | ), 56 | const _ErrorField(), 57 | const SizedBox(height: 16.0), 58 | _ButtonField( 59 | formKey: formKey, 60 | registerRequestModel: RegisterRequestModel( 61 | email: emailController.text.trim(), 62 | fullName: fullNameController.text.trim(), 63 | phoneNumber: phoneController.text.trim(), 64 | password: passwordController.text.trim(), 65 | ), 66 | ), 67 | const SizedBox(height: 16.0), 68 | ], 69 | ), 70 | ), 71 | ), 72 | ), 73 | ), 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/feature/auth/register/view/src/_button_field.dart: -------------------------------------------------------------------------------- 1 | part of '../register_view.dart'; 2 | 3 | final class _ButtonField extends StatelessWidget { 4 | const _ButtonField({ 5 | required this.formKey, 6 | required this.registerRequestModel, 7 | }); 8 | 9 | final GlobalKey formKey; 10 | final RegisterRequestModel registerRequestModel; 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return ElevatedButton( 15 | onPressed: () { 16 | formKey.currentState?.save(); 17 | if (formKey.currentState?.validate() ?? false) { 18 | context.read().register(registerRequestModel); 19 | } 20 | }, 21 | child: const Text('Register'), 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/feature/auth/register/view/src/_confirm_password_field.dart: -------------------------------------------------------------------------------- 1 | part of '../register_view.dart'; 2 | 3 | final class _ConfirmPasswordField extends StatelessWidget { 4 | const _ConfirmPasswordField({ 5 | required this.confirmPasswordController, 6 | required this.passwordController, 7 | }); 8 | 9 | final TextEditingController confirmPasswordController; 10 | final TextEditingController passwordController; 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return CustomTextField( 15 | name: 'Confirm Password', 16 | controller: confirmPasswordController, 17 | label: 'Confirm Password', 18 | validators: [ 19 | FormBuilderValidators.required( 20 | errorText: 'Confirm Password is required'), 21 | FormBuilderValidators.minLength(6, 22 | errorText: 'Password must be at least 6 characters'), 23 | FormBuilderValidators.equal( 24 | passwordController.text, 25 | errorText: 'Password does not match', 26 | ), 27 | ], 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/feature/auth/register/view/src/_email_field.dart: -------------------------------------------------------------------------------- 1 | part of '../register_view.dart'; 2 | 3 | final class _EmailField extends StatelessWidget { 4 | const _EmailField({ 5 | required this.emailController, 6 | }); 7 | 8 | final TextEditingController emailController; 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return CustomTextField( 13 | name: 'Email', 14 | controller: emailController, 15 | label: 'Email', 16 | validators: [ 17 | FormBuilderValidators.required(errorText: 'Email is required'), 18 | FormBuilderValidators.email(errorText: 'Invalid email'), 19 | ], 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/feature/auth/register/view/src/_error_field.dart: -------------------------------------------------------------------------------- 1 | part of '../register_view.dart'; 2 | 3 | final class _ErrorField extends StatelessWidget { 4 | const _ErrorField(); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return Selector( 9 | builder: (context, error, child) { 10 | return Text(error); 11 | }, 12 | selector: (context, viewModel) => viewModel.registerError ?? '', 13 | ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/feature/auth/register/view/src/_full_name_field.dart: -------------------------------------------------------------------------------- 1 | part of '../register_view.dart'; 2 | 3 | final class _FullNameField extends StatelessWidget { 4 | const _FullNameField({ 5 | required this.emailController, 6 | }); 7 | 8 | final TextEditingController emailController; 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return CustomTextField( 13 | name: 'FullName', 14 | controller: emailController, 15 | label: 'FullName', 16 | validators: [ 17 | FormBuilderValidators.required(errorText: 'FullName is required'), 18 | ], 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/feature/auth/register/view/src/_password_field.dart: -------------------------------------------------------------------------------- 1 | part of '../register_view.dart'; 2 | 3 | final class _PasswordField extends StatelessWidget { 4 | const _PasswordField({ 5 | required this.passwordController, 6 | }); 7 | 8 | final TextEditingController passwordController; 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return CustomTextField( 13 | name: 'Password', 14 | controller: passwordController, 15 | label: 'Password', 16 | validators: [ 17 | FormBuilderValidators.required(errorText: 'Password is required'), 18 | FormBuilderValidators.minLength(6, 19 | errorText: 'Password must be at least 6 characters'), 20 | ], 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/feature/auth/register/view/src/_phone_field.dart: -------------------------------------------------------------------------------- 1 | part of '../register_view.dart'; 2 | 3 | final class _PhoneField extends StatelessWidget { 4 | const _PhoneField({ 5 | required this.emailController, 6 | }); 7 | 8 | final TextEditingController emailController; 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return CustomTextField( 13 | name: 'Phone', 14 | controller: emailController, 15 | label: 'Phone', 16 | validators: [ 17 | FormBuilderValidators.required(errorText: 'Phone is required'), 18 | FormBuilderValidators.integer(errorText: 'Required as number') 19 | ], 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/feature/auth/register/view/src/register_view_mixin.dart: -------------------------------------------------------------------------------- 1 | part of '../register_view.dart'; 2 | 3 | mixin RegisterViewMixin on State { 4 | late final TextEditingController fullNameController; 5 | late final TextEditingController phoneController; 6 | late final TextEditingController emailController; 7 | late final TextEditingController passwordController; 8 | late final TextEditingController confirmPasswordController; 9 | late final GlobalKey formKey; 10 | late final RegisterViewModel registerViewModel; 11 | 12 | @override 13 | void initState() { 14 | registerViewModel = RegisterViewModel(FirebaseService()); 15 | fullNameController = TextEditingController(); 16 | phoneController = TextEditingController(); 17 | emailController = TextEditingController(); 18 | passwordController = TextEditingController(); 19 | confirmPasswordController = TextEditingController(); 20 | formKey = GlobalKey(); 21 | super.initState(); 22 | } 23 | 24 | @override 25 | void dispose() { 26 | fullNameController.dispose(); 27 | phoneController.dispose(); 28 | emailController.dispose(); 29 | passwordController.dispose(); 30 | confirmPasswordController.dispose(); 31 | formKey.currentState?.dispose(); 32 | super.dispose(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/feature/auth/register/view_model/register_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:tutorial_app/product/core/service/firebase_service.dart'; 3 | 4 | import '../model/register_request_model.dart'; 5 | 6 | final class RegisterViewModel extends ChangeNotifier { 7 | final FirebaseService _firebaseService; 8 | bool _registerSuccess = false; 9 | String? _registerError; 10 | 11 | RegisterViewModel(this._firebaseService); 12 | 13 | bool get registerSuccess => _registerSuccess; 14 | String? get registerError => _registerError; 15 | 16 | Future register(RegisterRequestModel registerRequestModel) async { 17 | final response = await _firebaseService 18 | .createUserWithEmailAndPassword(registerRequestModel); 19 | if (response.error != null) { 20 | _registerSuccess = false; 21 | _registerError = response.error; 22 | } else { 23 | _registerSuccess = true; 24 | _registerError = null; 25 | } 26 | if (hasListeners) { 27 | notifyListeners(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/feature/home/model/address.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | import '../../../product/core/model/base_model.dart'; 4 | import 'geo.dart'; 5 | 6 | part 'address.g.dart'; 7 | 8 | @JsonSerializable( 9 | checked: true, 10 | explicitToJson: true, 11 | ) 12 | final class Address extends BaseModel
{ 13 | final String? street; 14 | final String? suite; 15 | final String? city; 16 | final String? zipcode; 17 | final Geo? geo; 18 | 19 | const Address({ 20 | this.street, 21 | this.suite, 22 | this.city, 23 | this.zipcode, 24 | this.geo, 25 | }); 26 | 27 | Address copyWith({ 28 | String? street, 29 | String? suite, 30 | String? city, 31 | String? zipcode, 32 | Geo? geo, 33 | }) { 34 | return Address( 35 | street: street ?? this.street, 36 | suite: suite ?? this.suite, 37 | city: city ?? this.city, 38 | zipcode: zipcode ?? this.zipcode, 39 | geo: geo ?? this.geo, 40 | ); 41 | } 42 | 43 | @override 44 | Map toJson() => _$AddressToJson(this); 45 | 46 | factory Address.fromJson(Map json) => 47 | _$AddressFromJson(json); 48 | 49 | @override 50 | int get hashCode => Object.hash(street, suite, city, zipcode, geo); 51 | 52 | @override 53 | bool operator ==(Object other) => 54 | identical(this, other) || 55 | other is Address && 56 | runtimeType == other.runtimeType && 57 | street == other.street && 58 | suite == other.suite && 59 | city == other.city && 60 | zipcode == other.zipcode && 61 | geo == other.geo; 62 | 63 | @override 64 | Address fromJson(json) => Address.fromJson(json); 65 | 66 | @override 67 | List get props => [street, suite, city, zipcode, geo]; 68 | 69 | factory Address.empty() => const Address(); 70 | } 71 | -------------------------------------------------------------------------------- /lib/feature/home/model/address.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'address.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | Address _$AddressFromJson(Map json) => $checkedCreate( 10 | 'Address', 11 | json, 12 | ($checkedConvert) { 13 | final val = Address( 14 | street: $checkedConvert('street', (v) => v as String?), 15 | suite: $checkedConvert('suite', (v) => v as String?), 16 | city: $checkedConvert('city', (v) => v as String?), 17 | zipcode: $checkedConvert('zipcode', (v) => v as String?), 18 | geo: $checkedConvert( 19 | 'geo', 20 | (v) => 21 | v == null ? null : Geo.fromJson(v as Map)), 22 | ); 23 | return val; 24 | }, 25 | ); 26 | 27 | Map _$AddressToJson(Address instance) => { 28 | 'street': instance.street, 29 | 'suite': instance.suite, 30 | 'city': instance.city, 31 | 'zipcode': instance.zipcode, 32 | 'geo': instance.geo?.toJson(), 33 | }; 34 | -------------------------------------------------------------------------------- /lib/feature/home/model/company.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | import '../../../product/core/model/base_model.dart'; 4 | 5 | part 'company.g.dart'; 6 | 7 | @JsonSerializable( 8 | checked: true, 9 | explicitToJson: true, 10 | ) 11 | final class Company extends BaseModel { 12 | final String? name; 13 | final String? catchPhrase; 14 | final String? bs; 15 | 16 | const Company({ 17 | this.name, 18 | this.catchPhrase, 19 | this.bs, 20 | }); 21 | 22 | Company copyWith({ 23 | String? name, 24 | String? catchPhrase, 25 | String? bs, 26 | }) { 27 | return Company( 28 | name: name ?? this.name, 29 | catchPhrase: catchPhrase ?? this.catchPhrase, 30 | bs: bs ?? this.bs, 31 | ); 32 | } 33 | 34 | @override 35 | Map toJson() => _$CompanyToJson(this); 36 | 37 | factory Company.fromJson(Map json) => 38 | _$CompanyFromJson(json); 39 | 40 | @override 41 | Company fromJson(json) => Company.fromJson(json); 42 | 43 | @override 44 | List get props => [name, catchPhrase, bs]; 45 | 46 | factory Company.empty() => const Company(); 47 | } 48 | -------------------------------------------------------------------------------- /lib/feature/home/model/company.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'company.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | Company _$CompanyFromJson(Map json) => $checkedCreate( 10 | 'Company', 11 | json, 12 | ($checkedConvert) { 13 | final val = Company( 14 | name: $checkedConvert('name', (v) => v as String?), 15 | catchPhrase: $checkedConvert('catchPhrase', (v) => v as String?), 16 | bs: $checkedConvert('bs', (v) => v as String?), 17 | ); 18 | return val; 19 | }, 20 | ); 21 | 22 | Map _$CompanyToJson(Company instance) => { 23 | 'name': instance.name, 24 | 'catchPhrase': instance.catchPhrase, 25 | 'bs': instance.bs, 26 | }; 27 | -------------------------------------------------------------------------------- /lib/feature/home/model/geo.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | import 'package:tutorial_app/product/core/model/base_model.dart'; 3 | 4 | part 'geo.g.dart'; 5 | 6 | @JsonSerializable( 7 | checked: true, 8 | explicitToJson: true, 9 | ) 10 | final class Geo extends BaseModel { 11 | final String? lat; 12 | final String? lng; 13 | 14 | const Geo({ 15 | this.lat, 16 | this.lng, 17 | }); 18 | 19 | Geo copyWith({ 20 | String? lat, 21 | String? lng, 22 | }) { 23 | return Geo( 24 | lat: lat ?? this.lat, 25 | lng: lng ?? this.lng, 26 | ); 27 | } 28 | 29 | @override 30 | Map toJson() => _$GeoToJson(this); 31 | 32 | factory Geo.fromJson(Map json) => _$GeoFromJson(json); 33 | 34 | @override 35 | Geo fromJson(json) => Geo.fromJson(json); 36 | 37 | @override 38 | List get props => [lat, lng]; 39 | } 40 | -------------------------------------------------------------------------------- /lib/feature/home/model/geo.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'geo.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | Geo _$GeoFromJson(Map json) => $checkedCreate( 10 | 'Geo', 11 | json, 12 | ($checkedConvert) { 13 | final val = Geo( 14 | lat: $checkedConvert('lat', (v) => v as String?), 15 | lng: $checkedConvert('lng', (v) => v as String?), 16 | ); 17 | return val; 18 | }, 19 | ); 20 | 21 | Map _$GeoToJson(Geo instance) => { 22 | 'lat': instance.lat, 23 | 'lng': instance.lng, 24 | }; 25 | -------------------------------------------------------------------------------- /lib/feature/home/model/user_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'user_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | UserModel _$UserModelFromJson(Map json) => $checkedCreate( 10 | 'UserModel', 11 | json, 12 | ($checkedConvert) { 13 | final val = UserModel( 14 | id: $checkedConvert('id', (v) => v as int?), 15 | name: $checkedConvert('name', (v) => v as String?), 16 | username: $checkedConvert('username', (v) => v as String?), 17 | email: $checkedConvert('email', (v) => v as String?), 18 | address: $checkedConvert( 19 | 'address', 20 | (v) => v == null 21 | ? null 22 | : Address.fromJson(v as Map)), 23 | phone: $checkedConvert('phone', (v) => v as String?), 24 | website: $checkedConvert('website', (v) => v as String?), 25 | company: $checkedConvert( 26 | 'company', 27 | (v) => v == null 28 | ? null 29 | : Company.fromJson(v as Map)), 30 | ); 31 | return val; 32 | }, 33 | ); 34 | 35 | Map _$UserModelToJson(UserModel instance) => { 36 | 'id': instance.id, 37 | 'name': instance.name, 38 | 'username': instance.username, 39 | 'email': instance.email, 40 | 'address': instance.address?.toJson(), 41 | 'phone': instance.phone, 42 | 'website': instance.website, 43 | 'company': instance.company?.toJson(), 44 | }; 45 | -------------------------------------------------------------------------------- /lib/feature/home/model/user_response.dart: -------------------------------------------------------------------------------- 1 | import 'user_model.dart'; 2 | 3 | class UserResponse { 4 | bool? success; 5 | String? message; 6 | int? totalUsers; 7 | int? offset; 8 | int? limit; 9 | List? users; 10 | 11 | UserResponse({ 12 | this.success, 13 | this.message, 14 | this.totalUsers, 15 | this.offset, 16 | this.limit, 17 | this.users, 18 | }); 19 | 20 | UserResponse copyWith({ 21 | bool? success, 22 | String? message, 23 | int? totalUsers, 24 | int? offset, 25 | int? limit, 26 | List? users, 27 | }) { 28 | return UserResponse( 29 | success: success ?? this.success, 30 | message: message ?? this.message, 31 | totalUsers: totalUsers ?? this.totalUsers, 32 | offset: offset ?? this.offset, 33 | limit: limit ?? this.limit, 34 | users: users ?? this.users, 35 | ); 36 | } 37 | 38 | Map toJson() { 39 | return { 40 | 'success': success, 41 | 'message': message, 42 | 'total_users': totalUsers, 43 | 'offset': offset, 44 | 'limit': limit, 45 | 'users': users, 46 | }; 47 | } 48 | 49 | factory UserResponse.fromJson(Map json) { 50 | return UserResponse( 51 | success: json['success'] as bool?, 52 | message: json['message'] as String?, 53 | totalUsers: json['total_users'] as int?, 54 | offset: json['offset'] as int?, 55 | limit: json['limit'] as int?, 56 | users: (json['users'] as List?) 57 | ?.map((e) => UserModel.fromJson(e as Map)) 58 | .toList(), 59 | ); 60 | } 61 | 62 | @override 63 | String toString() => 64 | "Response(success: $success,message: $message,totalUsers: $totalUsers,offset: $offset,limit: $limit,users: $users)"; 65 | 66 | @override 67 | int get hashCode => 68 | Object.hash(success, message, totalUsers, offset, limit, users); 69 | 70 | @override 71 | bool operator ==(Object other) => 72 | identical(this, other) || 73 | other is UserResponse && 74 | runtimeType == other.runtimeType && 75 | success == other.success && 76 | message == other.message && 77 | totalUsers == other.totalUsers && 78 | offset == other.offset && 79 | limit == other.limit && 80 | users == other.users; 81 | } 82 | -------------------------------------------------------------------------------- /lib/feature/home/model/user_response_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'package:tutorial_app/feature/home/model/user_model.dart'; 3 | import 'package:tutorial_app/product/core/model/base_model.dart'; 4 | 5 | final class UsersResponseModel extends BaseModel { 6 | final List? users; 7 | final UserModel? user; 8 | final String? error; 9 | final int? statusCode; 10 | const UsersResponseModel({ 11 | this.users, 12 | this.user, 13 | this.error, 14 | this.statusCode, 15 | }); 16 | 17 | @override 18 | fromJson(dynamic json) { 19 | /// [dynamic] gelen veri önce jsonDecode ile decode edilir. 20 | final decodedData = jsonDecode(json); 21 | 22 | /// [decodedData] Map ise 23 | /// [user] parametresine [User] sınıfından bir nesne oluşturulur ve atanır. 24 | if (decodedData is Map) { 25 | return UsersResponseModel( 26 | users: (decodedData['users'] as List?) 27 | ?.map((e) => UserModel.fromJson(e as Map)) 28 | .cast() 29 | .toList(), 30 | ); 31 | } 32 | 33 | /// [decodedData] List ise 34 | /// içerisinde [User] sınıfı nesneleri barındıran bir liste oluşturulur. 35 | /// [decodedData] önce map'e çevrilir, map içerisindeki her bir eleman 36 | /// (e) ile temsil edilir ve [User] sınıfından bir nesne oluşturulur. 37 | /// Oluşturulan nesneler, [cast] methodu ile Liste içerisinde ki elemanların tipi 38 | /// [User] olarak kontrol eder, eğer tip hatalı gelirse [cast] hata döndürür. 39 | return UsersResponseModel( 40 | users: (decodedData as List?) 41 | ?.map((e) => UserModel.fromJson(e as Map)) 42 | .cast() 43 | .toList(), 44 | ); 45 | } 46 | 47 | @override 48 | Map toJson() { 49 | final users = this.users?.map((user) => user.toJson()).toList(); 50 | return { 51 | 'users': users, 52 | }; 53 | } 54 | 55 | @override 56 | List get props => [users, user, error, statusCode]; 57 | } 58 | -------------------------------------------------------------------------------- /lib/feature/home/service/home_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:tutorial_app/feature/home/model/user_response_model.dart'; 4 | 5 | import '../../../product/core/service/iservice_manager.dart'; 6 | import '../../../product/core/service/service_manager.dart'; 7 | 8 | final class HomeService { 9 | HomeService(IServiceManager service) : _service = service; 10 | 11 | /// [ServiceManager] sınıfından bir nesne oluşturulur. 12 | /// Bu sınıf ile API istekleri yapılır. 13 | /// parametre private olduğu için alt tire ile başlar. 14 | /// _service değişkenine dışarıdan erişim olmaması için private olarak tanımlanmıştır. 15 | /// Bu değişkenin dışarıdan erişim olmaması, sınıfın dışarıdan erişilebilirliğini azaltır. 16 | /// final değişken olduğu için sadece bir kere değer atanabilir. 17 | late final IServiceManager _service; 18 | 19 | Future getUsers() async { 20 | /// Kullanıcı listesi getirilir. 21 | /// [users] endpoint'i ile kullanıcı listesi getirilir. 22 | /// [model] parametresi parse edilecek modeli belirtir. 23 | /// [UsersResponseModel] dönüş tipi belirtilir. 24 | final response = await _service.get( 25 | 'users', 26 | model: const UsersResponseModel(), 27 | ); 28 | 29 | /// [response.statusCode] 200(HttpStatus.ok) değilse, hata döner. 30 | if (response.statusCode != HttpStatus.ok) { 31 | return UsersResponseModel( 32 | error: response.message, 33 | statusCode: response.statusCode, 34 | ); 35 | } 36 | 37 | /// [response.statusCode] 200(HttpStatus.ok) ise, kullanıcı listesi döner. 38 | return UsersResponseModel( 39 | users: response.data?.users, 40 | statusCode: response.statusCode, 41 | ); 42 | } 43 | 44 | Future getUser(int? id) async { 45 | /// [id] parametresi ile kullanıcı bilgileri getirilir. 46 | /// [id] parametresi null ise hata döner. 47 | if (id == null) { 48 | return const UsersResponseModel( 49 | error: 'Id is null', 50 | statusCode: HttpStatus.badRequest, 51 | ); 52 | } 53 | 54 | /// [id] parametresi ile kullanıcı bilgileri getirilir. 55 | final response = await _service.get( 56 | 'users/$id', 57 | model: const UsersResponseModel(), 58 | ); 59 | if (response.statusCode != HttpStatus.ok) { 60 | return UsersResponseModel( 61 | error: response.message, 62 | statusCode: response.statusCode, 63 | ); 64 | } 65 | return UsersResponseModel( 66 | user: response.data?.user, 67 | statusCode: response.statusCode, 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/feature/home/view/home_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:go_router/go_router.dart'; 3 | import 'package:provider/provider.dart'; 4 | import 'package:tutorial_app/feature/home/service/home_service.dart'; 5 | import 'package:tutorial_app/product/core/service/service_manager.dart'; 6 | import 'package:tutorial_app/product/utils/getit/product_state_items.dart'; 7 | import 'package:tutorial_app/product/widgets/shimmer/custom_list_shimmer.dart'; 8 | 9 | import '../../../product/utils/router/route_paths.dart'; 10 | import '../model/user_model.dart'; 11 | import '../view_model/home_view_model.dart'; 12 | 13 | part 'src/_list_view_builder.dart'; 14 | 15 | final class HomeView extends StatelessWidget { 16 | const HomeView({super.key}); 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | /// [ChangeNotifierProvider] sınıfı ile [HomeViewModel] sınıfı kullanılır. 21 | /// [HomeViewModel] sınıfı, kullanıcı listesi getirme işlemleri yapar. 22 | /// [HomeViewModel] sınıfı widget ağacına burada eklenir. 23 | /// Sadece içerisinde [HomeView] da gösterilecek değerler olduğu için 24 | /// burada oluşturulması en uygun yerdir. 25 | /// [create] parametresi ile [HomeViewModel] sınıfı oluşturulur. 26 | /// [HomeViewModel] sınıfı içerisinde [setUsers] metodu ile kullanıcı listesi getirilir. 27 | return ChangeNotifierProvider( 28 | create: (BuildContext context) => HomeViewModel( 29 | ProductStateItems.homeService, 30 | )..setUsers(), 31 | child: Scaffold( 32 | appBar: AppBar( 33 | title: const Text('Home'), 34 | ), 35 | 36 | /// Consumer sınıfı ile [HomeViewModel] sınıfı dinlenir. 37 | /// [HomeViewModel] sınıfı içerisindeki [users] ve [error] değişkenleri dinlenir. 38 | /// [users] değişkeni içerisinde kullanıcı listesi varsa, [ListViewBuilder] sınıfı ile kullanıcı listesi gösterilir. 39 | /// [error] değişkeni içerisinde hata varsa, hata mesajı gösterilir. 40 | /// [users] ve [error] değişkenleri null ise, yükleniyor gösterilir. 41 | /// [HomeViewModel] sınıfı içerisindeki [users] ve [error] değişkenleri değiştiğinde, bu widget yeniden oluşturulur. 42 | /// [Consumer] sınıfı [Provider] paketinden gelir. 43 | body: Consumer( 44 | builder: (context, viewModel, child) { 45 | if (viewModel.users != null && viewModel.users!.isNotEmpty) { 46 | /// [ListViewBuilder] sınıfı ile kullanıcı listesi gösterilir. 47 | /// [users] parametresi ile kullanıcı listesi alınır. 48 | /// [viewModel.users] değişkeni önceden kontrol edildiği için null olma ihtimali yoktur. 49 | /// fakat dart dili bunu anlamaz 50 | /// bu sebeple [!] işareti ile null force yapılır. 51 | /// Null kontrolü yapılmadığı durumlarda null foce [!] işareti yapılırsa hata alınır. 52 | return _ListViewBuilder(users: viewModel.users!); 53 | } else if (viewModel.error != null) { 54 | return Center( 55 | child: Text(viewModel.error ?? ''), 56 | ); 57 | } 58 | return const Center( 59 | child: CustomListShimmer(), 60 | ); 61 | }, 62 | ), 63 | ), 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/feature/home/view/src/_list_view_builder.dart: -------------------------------------------------------------------------------- 1 | part of '../home_view.dart'; 2 | 3 | final class _ListViewBuilder extends StatelessWidget { 4 | const _ListViewBuilder({ 5 | required this.users, 6 | }); 7 | 8 | /// Kullanıcı listesi 9 | /// Bu liste nullable değildir. 10 | /// Listenin boş olma durumu kontrol edilmiştir. 11 | /// Eğer liste boş ise bir önceki sayfada bu widget çalışmayacağı için 12 | /// kontrol edilmesine gerek yoktur. 13 | final List users; 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return ListView.builder( 18 | shrinkWrap: true, 19 | padding: const EdgeInsets.all(8), 20 | itemCount: users.length, 21 | itemBuilder: (context, index) { 22 | /// Kullanıcı listesi içerisindeki her bir kullanıcı için bir [Card] oluşturulur. 23 | /// [Card] içerisinde [ListTile] oluşturulur. 24 | /// [ListTile] içerisinde kullanıcı bilgileri gösterilir. 25 | /// [user] parametresi her bir kullanıcıyı temsil eder. 26 | /// ListView.builder'dan gelen index değeri her bir kullanıcı için kullanılır. 27 | final user = users[index]; 28 | return Card( 29 | child: ListTile( 30 | /// Kullanıcı adı null olma durumunda boş bir string gösterilir. 31 | onTap: () { 32 | context.push( 33 | RoutePaths.userDetail.path, 34 | extra: user, 35 | ); 36 | }, 37 | title: Text(user.name ?? ''), 38 | subtitle: Text(user.email ?? ''), 39 | trailing: Text(user.address?.city ?? ''), 40 | ), 41 | ); 42 | }, 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/feature/photos/model/photo_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | import 'package:tutorial_app/product/core/model/base_model.dart'; 3 | import 'photos.dart'; 4 | part 'photo_response.g.dart'; 5 | 6 | @JsonSerializable() 7 | final class PhotoResponse extends BaseModel { 8 | final bool? success; 9 | final int? totalPhotos; 10 | final String? message; 11 | final int? offset; 12 | final int? limit; 13 | final List? photos; 14 | 15 | const PhotoResponse({ 16 | this.success, 17 | this.totalPhotos, 18 | this.message, 19 | this.offset, 20 | this.limit, 21 | this.photos, 22 | }); 23 | 24 | factory PhotoResponse.fromJson(Map json) => 25 | _$PhotoResponseFromJson(json); 26 | 27 | @override 28 | Map toJson() => _$PhotoResponseToJson(this); 29 | 30 | PhotoResponse copyWith({ 31 | bool? success, 32 | int? totalPhotos, 33 | String? message, 34 | int? offset, 35 | int? limit, 36 | List? photos, 37 | }) { 38 | return PhotoResponse( 39 | success: success ?? this.success, 40 | totalPhotos: totalPhotos ?? this.totalPhotos, 41 | message: message ?? this.message, 42 | offset: offset ?? this.offset, 43 | limit: limit ?? this.limit, 44 | photos: photos ?? this.photos, 45 | ); 46 | } 47 | 48 | @override 49 | PhotoResponse fromJson(json) => PhotoResponse.fromJson(json); 50 | 51 | @override 52 | List get props => [ 53 | success, 54 | totalPhotos, 55 | message, 56 | offset, 57 | limit, 58 | photos, 59 | ]; 60 | } 61 | -------------------------------------------------------------------------------- /lib/feature/photos/model/photo_response.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'photo_response.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | PhotoResponse _$PhotoResponseFromJson(Map json) => 10 | PhotoResponse( 11 | success: json['success'] as bool?, 12 | totalPhotos: json['totalPhotos'] as int?, 13 | message: json['message'] as String?, 14 | offset: json['offset'] as int?, 15 | limit: json['limit'] as int?, 16 | photos: (json['photos'] as List?) 17 | ?.map((e) => Photos.fromJson(e as Map)) 18 | .toList(), 19 | ); 20 | 21 | Map _$PhotoResponseToJson(PhotoResponse instance) => 22 | { 23 | 'success': instance.success, 24 | 'totalPhotos': instance.totalPhotos, 25 | 'message': instance.message, 26 | 'offset': instance.offset, 27 | 'limit': instance.limit, 28 | 'photos': instance.photos, 29 | }; 30 | -------------------------------------------------------------------------------- /lib/feature/photos/model/photos.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | import '../../../product/core/model/base_model.dart'; 4 | part 'photos.g.dart'; 5 | 6 | @JsonSerializable() 7 | final class Photos extends BaseModel { 8 | final String? url; 9 | final String? title; 10 | final int? user; 11 | @JsonKey(name: '_id') 12 | final int? id; 13 | final String? description; 14 | 15 | const Photos({ 16 | this.url, 17 | this.title, 18 | this.user, 19 | this.id, 20 | this.description, 21 | }); 22 | 23 | factory Photos.fromJson(Map json) => _$PhotosFromJson(json); 24 | 25 | @override 26 | Map toJson() => _$PhotosToJson(this); 27 | 28 | Photos copyWith({ 29 | String? url, 30 | String? title, 31 | int? user, 32 | int? id, 33 | String? description, 34 | }) { 35 | return Photos( 36 | url: url ?? this.url, 37 | title: title ?? this.title, 38 | user: user ?? this.user, 39 | id: id ?? this.id, 40 | description: description ?? this.description, 41 | ); 42 | } 43 | 44 | @override 45 | Photos fromJson(json) => Photos.fromJson(json); 46 | 47 | @override 48 | List get props => [url, title, user, id, description]; 49 | } 50 | -------------------------------------------------------------------------------- /lib/feature/photos/model/photos.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'photos.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | Photos _$PhotosFromJson(Map json) => Photos( 10 | url: json['url'] as String?, 11 | title: json['title'] as String?, 12 | user: json['user'] as int?, 13 | id: json['_id'] as int?, 14 | description: json['description'] as String?, 15 | ); 16 | 17 | Map _$PhotosToJson(Photos instance) => { 18 | 'url': instance.url, 19 | 'title': instance.title, 20 | 'user': instance.user, 21 | '_id': instance.id, 22 | 'description': instance.description, 23 | }; 24 | -------------------------------------------------------------------------------- /lib/feature/photos/model/photos_response_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'package:tutorial_app/feature/photos/model/photo_response.dart'; 3 | import 'package:tutorial_app/feature/photos/model/photos.dart'; 4 | import 'package:tutorial_app/product/core/model/base_model.dart'; 5 | 6 | final class PhotosResponseModel extends BaseModel { 7 | final PhotoResponse? photos; 8 | final Photos? photo; 9 | final String? error; 10 | final int? statusCode; 11 | const PhotosResponseModel({ 12 | this.photos, 13 | this.photo, 14 | this.error, 15 | this.statusCode, 16 | }); 17 | 18 | @override 19 | fromJson(dynamic json) { 20 | /// [dynamic] gelen veri önce jsonDecode ile decode edilir. 21 | final decodedData = jsonDecode(json); 22 | 23 | /// [decodedData] Map ise 24 | /// [user] parametresine [User] sınıfından bir nesne oluşturulur ve atanır. 25 | if (decodedData is Map) { 26 | return PhotosResponseModel( 27 | photos: PhotoResponse.fromJson(decodedData as Map), 28 | ); 29 | } else if (decodedData is List) { 30 | return PhotosResponseModel( 31 | photos: PhotoResponse.fromJson({'photos': decodedData}), 32 | ); 33 | } else { 34 | return const PhotosResponseModel( 35 | error: 'Json decode error', 36 | ); 37 | } 38 | } 39 | 40 | @override 41 | Map toJson() { 42 | final photos = this.photos?.toJson(); 43 | return { 44 | 'photos': photos, 45 | }; 46 | } 47 | 48 | @override 49 | List get props => [photos, photo, error, statusCode]; 50 | } 51 | -------------------------------------------------------------------------------- /lib/feature/photos/service/photos_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:tutorial_app/feature/photos/model/photos_response_model.dart'; 4 | 5 | import '../../../product/core/service/iservice_manager.dart'; 6 | import '../../../product/core/service/service_manager.dart'; 7 | 8 | final class PhotosService { 9 | PhotosService(this._service); 10 | 11 | /// [ServiceManager] sınıfından bir nesne oluşturulur. 12 | /// Bu sınıf ile API istekleri yapılır. 13 | /// parametre private olduğu için alt tire ile başlar. 14 | /// _service değişkenine dışarıdan erişim olmaması için private olarak tanımlanmıştır. 15 | /// Bu değişkenin dışarıdan erişim olmaması, sınıfın dışarıdan erişilebilirliğini azaltır. 16 | /// final değişken olduğu için sadece bir kere değer atanabilir. 17 | late final IServiceManager _service; 18 | 19 | Future getPhotos(int start, int end) async { 20 | /// Kullanıcı listesi getirilir. 21 | /// [users] endpoint'i ile kullanıcı listesi getirilir. 22 | /// [model] parametresi parse edilecek modeli belirtir. 23 | /// [UsersResponseModel] dönüş tipi belirtilir. 24 | final response = await _service.get( 25 | 'photos?offset=$start&limit=$end', 26 | model: const PhotosResponseModel(), 27 | ); 28 | 29 | /// [response.statusCode] 200(HttpStatus.ok) değilse, hata döner. 30 | if (response.statusCode != HttpStatus.ok) { 31 | return PhotosResponseModel( 32 | error: response.message, 33 | statusCode: response.statusCode, 34 | ); 35 | } 36 | 37 | /// [response.statusCode] 200(HttpStatus.ok) ise, kullanıcı listesi döner. 38 | return PhotosResponseModel( 39 | photos: response.data?.photos, 40 | statusCode: response.statusCode, 41 | ); 42 | } 43 | 44 | Future getPhoto(int? id) async { 45 | /// [id] parametresi ile kullanıcı bilgileri getirilir. 46 | /// [id] parametresi null ise hata döner. 47 | if (id == null) { 48 | return const PhotosResponseModel( 49 | error: 'Id is null', 50 | statusCode: HttpStatus.badRequest, 51 | ); 52 | } 53 | 54 | /// [id] parametresi ile kullanıcı bilgileri getirilir. 55 | final response = await _service.get('photos/$id', 56 | model: const PhotosResponseModel()); 57 | if (response.statusCode != HttpStatus.ok) { 58 | return PhotosResponseModel( 59 | error: response.message, 60 | statusCode: response.statusCode, 61 | ); 62 | } 63 | return PhotosResponseModel( 64 | photos: response.data?.photos, 65 | statusCode: response.statusCode, 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/feature/photos/view/photos_view.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:easy_localization/easy_localization.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:provider/provider.dart'; 6 | import 'package:tutorial_app/product/utils/getit/product_state_items.dart'; 7 | import 'package:tutorial_app/product/utils/localization/locale_keys.g.dart'; 8 | import 'package:tutorial_app/product/widgets/shimmer/custom_image_shimmer.dart'; 9 | 10 | import '../view_model/ptohos_view_model.dart'; 11 | 12 | part 'src/_photos_gridview_builder.dart'; 13 | 14 | final class PhotosView extends StatelessWidget { 15 | const PhotosView({super.key}); 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return Scaffold( 20 | appBar: AppBar( 21 | title: Text(LocaleKeys.photos_title.tr()), 22 | ), 23 | body: ChangeNotifierProvider( 24 | create: (BuildContext context) => PhotosViewModel( 25 | ProductStateItems.photoService, 26 | )..getPhotos( 27 | 0, 28 | 10, 29 | ), 30 | child: Consumer( 31 | builder: (context, viewModel, child) { 32 | if (viewModel.statusCode != HttpStatus.ok) { 33 | return const Center( 34 | child: CustomImageShimmer(), 35 | ); 36 | } 37 | return const _PhotosGridViewBuilder(); 38 | }, 39 | ), 40 | ), 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/feature/photos/view/src/_photos_gridview_builder.dart: -------------------------------------------------------------------------------- 1 | part of '../photos_view.dart'; 2 | 3 | final class _PhotosGridViewBuilder extends StatelessWidget { 4 | const _PhotosGridViewBuilder(); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | final viewModel = context.read(); 9 | return Column( 10 | children: [ 11 | Flexible( 12 | child: GridView.builder( 13 | shrinkWrap: true, 14 | itemCount: viewModel.data?.photos?.length ?? 0, 15 | gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( 16 | crossAxisCount: 2, 17 | ), 18 | itemBuilder: (context, index) { 19 | return Container( 20 | margin: const EdgeInsets.all(8), 21 | decoration: BoxDecoration( 22 | image: DecorationImage( 23 | image: 24 | NetworkImage(viewModel.data?.photos?[index].url ?? ''), 25 | fit: BoxFit.cover, 26 | ), 27 | borderRadius: BorderRadius.circular(8), 28 | color: Colors.grey, 29 | ), 30 | ); 31 | }, 32 | ), 33 | ), 34 | Container( 35 | color: Theme.of(context).colorScheme.surfaceBright, 36 | height: 50, 37 | child: Row( 38 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 39 | children: [ 40 | Row( 41 | children: [ 42 | IconButton( 43 | onPressed: () { 44 | viewModel.getPhotos( 45 | 0, 46 | 10, 47 | ); 48 | }, 49 | icon: const Icon(Icons.first_page), 50 | ), 51 | IconButton( 52 | onPressed: () { 53 | if ((viewModel.data?.offset ?? 0) - 10 < 0) { 54 | return; 55 | } 56 | viewModel.getPhotos( 57 | (viewModel.data?.offset ?? 0) - 10, 58 | (viewModel.data?.limit ?? 10) - 10, 59 | ); 60 | }, 61 | icon: const Icon(Icons.arrow_back), 62 | ), 63 | ], 64 | ), 65 | Text( 66 | '${viewModel.data?.offset ?? 0} - ${(viewModel.data?.limit ?? 10)}', 67 | ), 68 | IconButton( 69 | onPressed: () { 70 | viewModel.getPhotos( 71 | (viewModel.data?.offset ?? 0) + 10, 72 | (viewModel.data?.limit ?? 10) + 10, 73 | ); 74 | }, 75 | icon: const Icon(Icons.arrow_forward), 76 | ), 77 | const SizedBox.shrink() 78 | ], 79 | ), 80 | ) 81 | ], 82 | ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /lib/feature/photos/view_model/ptohos_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:tutorial_app/feature/photos/model/photo_response.dart'; 3 | import 'package:tutorial_app/feature/photos/model/photos.dart'; 4 | import 'package:tutorial_app/feature/photos/service/photos_service.dart'; 5 | 6 | /// [ChangeNotifier] sınıfından bir nesne oluşturulur. 7 | /// Bu sınıf ile [PhotosService] sınıfından gelen veriler işlenir. 8 | /// [ChangeNotifier] sınıfı ile [Provider] paketi kullanılarak state management yapılır. 9 | /// [ChangeNotifier] sınıfı, [notifyListeners] metodu ile dinleyen widget'ları günceller. 10 | /// [notifyListeners] metodu, [ChangeNotifier] sınıfının içerisindeki değişkenlerde 11 | /// değişiklik olduğunda çalıştırılır. 12 | final class PhotosViewModel extends ChangeNotifier { 13 | PhotosViewModel(this._photosService); 14 | 15 | /// [PhotosViewModel] sınıfının değişkenleri private olarak tanımlanmıştır. 16 | /// Bu değişkenleri dışarıdan doğrudan erişim olmaması içindir. 17 | /// Bu değişkenlere dışarıdan erişim yapmak için get metotları kullanılır. 18 | /// Bu değişkenlerin dışarıdan erişim olmaması, sınıfın dışarıdan erişilebilirliğini azaltır. 19 | /// Bu değişkenler sadefe fonksiyonlar içerisinde kullanılır. 20 | /// ve sadece o şekilde güncellenir. 21 | /// Dışarıdan güncellenmesi için set metotları kullanılır. 22 | // set setPhoto(List? value) { 23 | // _photo = value; 24 | // notifyListeners(); 25 | // } 26 | PhotoResponse? _data; 27 | Photos? _photo; 28 | int? _statusCode; 29 | String? _error; 30 | 31 | /// [HomeViewModel] sınıfına ait değişkenlere erişmek için get metotları kullanılır. 32 | /// Bu metotlar dışarıdan erişim sağlar. 33 | /// get metotları sadece getter işlemi yapar, değişkenlere değer ataması yapmaz. 34 | PhotoResponse? get data => _data; 35 | Photos? get photo => _photo; 36 | int? get statusCode => _statusCode; 37 | String? get error => _error; 38 | 39 | /// [PhotoService] sınıfından bir nesne oluşturulur. 40 | /// Bu sınıf ile [ServiceManager] dan gelen veriler işlenir. 41 | late final PhotosService _photosService; 42 | 43 | Future getPhotos(int start, int end) async { 44 | /// Kullanıcı listesi getirilir. 45 | final response = await _photosService.getPhotos(start, end); 46 | 47 | /// [response.photos] kullanıcı listesi [_photos] değişkenine atanır. 48 | _data = response.photos; 49 | 50 | /// [response.statusCode] durum kodu _statusCode değişkenine atanır. 51 | _statusCode = response.statusCode; 52 | 53 | /// [response.error] hata mesajı _error değişkenine atanır. 54 | _error = response.error; 55 | 56 | /// [notifyListeners] metodu ile dinleyen widget'ları günceller. 57 | /// [hasListeners] metodu ile dinleyen widget'lar var mı kontrol edilir. 58 | /// Eğer varsa [notifyListeners] metodu çalıştırılır. 59 | /// Bu sayede dinleyen widget'lar güncellenir. 60 | /// Dinleyen widget'lar güncellendikten sonra, [Consumer] sınıfı ile bu widget'lar yeniden oluşturulur. 61 | /// Dinleyen bir widget yoksa, [notifyListeners] metodu çalıştırılmaz. 62 | /// Bu sayede gereksiz yere widget'lar yeniden oluşturulmaz. 63 | /// Bu durumda performans artışı sağlanır. 64 | /// Ve dispose olmuş widget'lar gereksiz yere yeniden oluşturulmaz ve hata almaz. 65 | if (hasListeners) { 66 | notifyListeners(); 67 | } 68 | } 69 | 70 | void getPhoto(int id) async { 71 | /// [id] parametresi ile kullanıcı bilgileri getirilir. 72 | final response = await _photosService.getPhoto(id); 73 | _photo = response.photo; 74 | _statusCode = response.statusCode; 75 | _error = response.error; 76 | if (hasListeners) { 77 | notifyListeners(); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /lib/feature/profile/model/profile_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | import 'package:tutorial_app/product/core/model/base_model.dart'; 3 | 4 | part 'profile_model.g.dart'; 5 | 6 | @JsonSerializable() 7 | final class ProfileModel extends BaseModel { 8 | final String? fullName; 9 | final String? email; 10 | final String? phoneNumber; 11 | 12 | const ProfileModel({this.fullName, this.email, this.phoneNumber}); 13 | 14 | @override 15 | ProfileModel fromJson(json) => _$ProfileModelFromJson(json); 16 | 17 | @override 18 | List get props => [ 19 | fullName, 20 | email, 21 | phoneNumber, 22 | ]; 23 | 24 | @override 25 | Map toJson() => _$ProfileModelToJson(this); 26 | } 27 | -------------------------------------------------------------------------------- /lib/feature/profile/model/profile_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'profile_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | ProfileModel _$ProfileModelFromJson(Map json) => ProfileModel( 10 | fullName: json['fullName'] as String?, 11 | email: json['email'] as String?, 12 | phoneNumber: json['phoneNumber'] as String?, 13 | ); 14 | 15 | Map _$ProfileModelToJson(ProfileModel instance) => 16 | { 17 | 'fullName': instance.fullName, 18 | 'email': instance.email, 19 | 'phoneNumber': instance.phoneNumber, 20 | }; 21 | -------------------------------------------------------------------------------- /lib/feature/profile/view/profile_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:provider/provider.dart'; 3 | import 'package:tutorial_app/feature/auth/login/view_model/login_view_model.dart'; 4 | import 'package:tutorial_app/feature/profile/model/profile_model.dart'; 5 | import 'package:tutorial_app/feature/profile/view_model/profile_view_model.dart'; 6 | 7 | part 'profile_view_mixin.dart'; 8 | 9 | class ProfileView extends StatefulWidget { 10 | const ProfileView({super.key}); 11 | 12 | @override 13 | State createState() => _ProfileViewState(); 14 | } 15 | 16 | class _ProfileViewState extends State with ProfileViewMixin { 17 | @override 18 | Widget build(BuildContext context) { 19 | return Scaffold( 20 | appBar: AppBar(title: const Text('Profile')), 21 | body: SingleChildScrollView( 22 | child: MultiProvider( 23 | providers: [ 24 | ChangeNotifierProvider( 25 | create: (context) => _profileViewModel..fetchUser(), 26 | ), 27 | ChangeNotifierProvider( 28 | create: (context) => LoginViewModel(), 29 | ) 30 | ], 31 | child: Column( 32 | children: [ 33 | Consumer( 34 | builder: (context, snapshot, child) { 35 | if (snapshot.error != null) { 36 | return Center(child: Text(snapshot.error ?? '')); 37 | } else if (snapshot.userModel != null) { 38 | return ProfileField(userModel: snapshot.userModel!); 39 | } else { 40 | return const Center( 41 | child: CircularProgressIndicator.adaptive()); 42 | } 43 | }, 44 | ), 45 | const SizedBox( 46 | height: 20, 47 | ), 48 | const _LogoutButton() 49 | ], 50 | ), 51 | ), 52 | ), 53 | ); 54 | } 55 | } 56 | 57 | class _LogoutButton extends StatelessWidget { 58 | const _LogoutButton(); 59 | 60 | @override 61 | Widget build(BuildContext context) { 62 | return ElevatedButton( 63 | onPressed: () async { 64 | context.read().logout(); 65 | await context.read().logout(); 66 | }, 67 | child: const Text('Logout')); 68 | } 69 | } 70 | 71 | class ProfileField extends StatelessWidget { 72 | const ProfileField({ 73 | super.key, 74 | required this.userModel, 75 | }); 76 | 77 | final ProfileModel userModel; 78 | 79 | @override 80 | Widget build(BuildContext context) { 81 | return Column( 82 | children: [ 83 | ListTile( 84 | title: Text(userModel.email ?? ''), 85 | ), 86 | ListTile( 87 | title: Text(userModel.fullName ?? ''), 88 | ), 89 | ListTile( 90 | title: Text(userModel.phoneNumber ?? ''), 91 | ), 92 | ], 93 | ); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /lib/feature/profile/view/profile_view_mixin.dart: -------------------------------------------------------------------------------- 1 | part of 'profile_view.dart'; 2 | 3 | mixin ProfileViewMixin on State { 4 | late final ProfileViewModel _profileViewModel; 5 | @override 6 | void initState() { 7 | _profileViewModel = ProfileViewModel(); 8 | super.initState(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/feature/profile/view_model/profile_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:firebase_auth/firebase_auth.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:tutorial_app/product/core/service/firebase_service.dart'; 4 | 5 | import '../model/profile_model.dart'; 6 | 7 | final class ProfileViewModel extends ChangeNotifier { 8 | ProfileModel? _userModel; 9 | String? _error; 10 | bool? _isSuccess; 11 | final FirebaseService _firebaseService = FirebaseService(); 12 | 13 | ProfileModel? get userModel => _userModel; 14 | String? get error => _error; 15 | bool? get isSuccess => _isSuccess; 16 | 17 | Future fetchUser() async { 18 | final currentUser = FirebaseAuth.instance.currentUser; 19 | 20 | final response = 21 | await _firebaseService.getModelFirebaseFirestore( 22 | colPath: FirestorePath.users, 23 | docPath: currentUser?.uid, 24 | model: const ProfileModel(), 25 | ); 26 | _userModel = response.data; 27 | _error = response.error; 28 | _isSuccess = response.isSuccess; 29 | if (!hasListeners) return; 30 | notifyListeners(); 31 | } 32 | 33 | Future logout() async { 34 | _userModel = null; 35 | _error = null; 36 | _isSuccess = null; 37 | await FirebaseAuth.instance.signOut(); 38 | if (!hasListeners) return; 39 | notifyListeners(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/feature/splash/view/splash_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:tutorial_app/feature/home/view/home_view.dart'; 3 | import 'package:tutorial_app/feature/photos/view/photos_view.dart'; 4 | import 'package:tutorial_app/feature/test_page/view/test_view.dart'; 5 | 6 | import '../../auth/auth_splash/view/auth_splash_view.dart'; 7 | 8 | class SplashView extends StatefulWidget { 9 | const SplashView({super.key}); 10 | 11 | @override 12 | State createState() => _SplashViewState(); 13 | } 14 | 15 | class _SplashViewState extends State { 16 | final items = [ 17 | const BottomNavigationBarItem( 18 | icon: Icon(Icons.home), 19 | label: 'Home', 20 | ), 21 | const BottomNavigationBarItem( 22 | icon: Icon(Icons.image), 23 | label: 'Photos', 24 | ), 25 | const BottomNavigationBarItem( 26 | icon: Icon(Icons.settings), 27 | label: 'Tests', 28 | ), 29 | const BottomNavigationBarItem( 30 | icon: Icon(Icons.person), 31 | label: 'Profile', 32 | ), 33 | ]; 34 | 35 | int _selectedIndex = 0; 36 | 37 | final _widgetOptions = [ 38 | const HomeView(), 39 | const PhotosView(), 40 | const TestView(), 41 | const AuthSplashView() 42 | ]; 43 | 44 | @override 45 | Widget build(BuildContext context) { 46 | return Scaffold( 47 | body: _widgetOptions.elementAt(_selectedIndex), 48 | bottomNavigationBar: BottomNavigationBar( 49 | selectedItemColor: Colors.black26, 50 | unselectedItemColor: Colors.black45, 51 | items: items, 52 | currentIndex: _selectedIndex, 53 | onTap: (index) { 54 | setState(() { 55 | _selectedIndex = index; 56 | }); 57 | }, 58 | ), 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/feature/test_page/model/comments_model.dart: -------------------------------------------------------------------------------- 1 | class Comment { 2 | final int? postId; 3 | final int? id; 4 | final String? name; 5 | final String? email; 6 | final String? body; 7 | 8 | Comment({ 9 | this.postId, 10 | this.id, 11 | this.name, 12 | this.email, 13 | this.body, 14 | }); 15 | 16 | Comment copyWith({ 17 | int? postId, 18 | int? id, 19 | String? name, 20 | String? email, 21 | String? body, 22 | }) { 23 | return Comment( 24 | postId: postId ?? this.postId, 25 | id: id ?? this.id, 26 | name: name ?? this.name, 27 | email: email ?? this.email, 28 | body: body ?? this.body, 29 | ); 30 | } 31 | 32 | Map toJson() { 33 | return { 34 | 'postId': postId, 35 | 'id': id, 36 | 'name': name, 37 | 'email': email, 38 | 'body': body, 39 | }; 40 | } 41 | 42 | factory Comment.fromJson(Map json) { 43 | return Comment( 44 | postId: json['postId'] as int?, 45 | id: json['id'] as int?, 46 | name: json['name'] as String?, 47 | email: json['email'] as String?, 48 | body: json['body'] as String?, 49 | ); 50 | } 51 | 52 | @override 53 | String toString() => 54 | "Comment(postId: $postId,id: $id,name: $name,email: $email,body: $body)"; 55 | 56 | @override 57 | int get hashCode => Object.hash(postId, id, name, email, body); 58 | 59 | @override 60 | bool operator ==(Object other) => 61 | identical(this, other) || 62 | other is Comment && 63 | runtimeType == other.runtimeType && 64 | postId == other.postId && 65 | id == other.id && 66 | name == other.name && 67 | email == other.email && 68 | body == other.body; 69 | } 70 | -------------------------------------------------------------------------------- /lib/feature/test_page/view/test_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:provider/provider.dart'; 3 | import 'package:tutorial_app/feature/test_page/view_model/test_view_model.dart'; 4 | 5 | class TestView extends StatelessWidget { 6 | const TestView({super.key}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return ChangeNotifierProvider( 11 | create: (context) => TestViewModel(), 12 | child: Scaffold( 13 | appBar: AppBar( 14 | title: const Text('Test View'), 15 | ), 16 | body: Padding( 17 | padding: const EdgeInsets.all(8.0), 18 | child: Column( 19 | children: [ 20 | const Expanded(child: _GetConfigValueButton()), 21 | Expanded( 22 | flex: 5, 23 | child: Consumer( 24 | builder: (context, state, _) { 25 | if (state.getCommentList == null) return Container(); 26 | return ListView.builder( 27 | shrinkWrap: true, 28 | itemCount: state.getCommentList?.length, 29 | itemBuilder: (context, index) { 30 | final comment = state.getCommentList?[index]; 31 | if (comment != null) { 32 | return Text(comment.body ?? ''); 33 | } 34 | return Container(); 35 | }); 36 | }, 37 | ), 38 | ) 39 | ], 40 | ), 41 | ), 42 | ), 43 | ); 44 | } 45 | } 46 | 47 | class _GetConfigValueButton extends StatelessWidget { 48 | const _GetConfigValueButton(); 49 | 50 | @override 51 | Widget build(BuildContext context) { 52 | return ElevatedButton( 53 | onPressed: () => context.read().getConfigValue(), 54 | child: const Text('Get Quests')); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/feature/test_page/view_model/test_view_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:tutorial_app/feature/test_page/model/comments_model.dart'; 5 | import 'package:tutorial_app/product/utils/remote_config/remote_config_manager.dart'; 6 | 7 | final class TestViewModel extends ChangeNotifier { 8 | List? _commentList; 9 | 10 | List? get getCommentList => _commentList; 11 | 12 | void getConfigValue() { 13 | final response = RemoteConfigManager.getString('quest'); 14 | final decodedString = json.decode(response); 15 | final newList = 16 | decodedString.map((e) => Comment.fromJson(e)).cast().toList(); 17 | _commentList = newList; 18 | if (!hasListeners) return; 19 | notifyListeners(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/info.md: -------------------------------------------------------------------------------- 1 | Google Maps Android Konfigürasyonları yapılmadı, Android'de çalıştırmak için Google Map ayarlarını yapıp kendi API KEY'inizi yazmanız gerekmektedir. 2 | https://pub.dev/packages/google_maps_flutter 3 | 4 | -------------------------------------------------------------------------------- /lib/product/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/lib/product/.DS_Store -------------------------------------------------------------------------------- /lib/product/core/constants/remote_config_keys.dart: -------------------------------------------------------------------------------- 1 | final class RemoteConfigKeys { 2 | RemoteConfigKeys._(); 3 | 4 | static const String themeMode = 'themeMode'; 5 | static const String wellcomeMessage = 'wellcomeMessage'; 6 | static const String loginBackgroundImage = 'loginBackgroundImage'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/product/core/enums/firebase_status.dart: -------------------------------------------------------------------------------- 1 | import '../../utils/localization/locale_keys.g.dart'; 2 | 3 | enum FirebaseStatus { 4 | success(LocaleKeys.erroStatus_success), 5 | userNotFound(LocaleKeys.erroStatus_userNotFound), 6 | weakPassword(LocaleKeys.erroStatus_weakPassword), 7 | tooManyRequests(LocaleKeys.erroStatus_tooManyRequests), 8 | undefined(LocaleKeys.erroStatus_undefined), 9 | wrongPassword(LocaleKeys.erroStatus_wrongPassword), 10 | emailAlreadyInUse(LocaleKeys.erroStatus_emailAlreadyInUse), 11 | invalidEmail(LocaleKeys.erroStatus_invalidEmail), 12 | userDisabled(LocaleKeys.erroStatus_userDisabled), 13 | operationNotAllowed(LocaleKeys.erroStatus_operationNotAllowed), 14 | invalidPassword(LocaleKeys.erroStatus_invalidPassword), 15 | invalidArgument(LocaleKeys.erroStatus_invalidArgument), 16 | notFound(LocaleKeys.erroStatus_notFound), 17 | alreadyExists(LocaleKeys.erroStatus_alreadyExists), 18 | permissionDenied(LocaleKeys.erroStatus_permissionDenied), 19 | unauthenticated(LocaleKeys.erroStatus_unauthenticated), 20 | resourceExhausted(LocaleKeys.erroStatus_resourceExhausted), 21 | aborted(LocaleKeys.erroStatus_aborted), 22 | outOfRange(LocaleKeys.erroStatus_outOfRange), 23 | unimplemented(LocaleKeys.erroStatus_unimplemented), 24 | internal(LocaleKeys.erroStatus_internal), 25 | unavailable(LocaleKeys.erroStatus_unavailable), 26 | dataLoss(LocaleKeys.erroStatus_dataLoss), 27 | emailNotVerified(LocaleKeys.erroStatus_verifyEmail), 28 | invalidLoginCredentials(LocaleKeys.erroStatus_invalidCredential), 29 | ; 30 | 31 | final String value; 32 | const FirebaseStatus(this.value); 33 | } 34 | -------------------------------------------------------------------------------- /lib/product/core/enums/shared_manager_enums.dart: -------------------------------------------------------------------------------- 1 | enum SharedManagerEnums { 2 | email, 3 | password, 4 | token, 5 | savedUser, 6 | } 7 | -------------------------------------------------------------------------------- /lib/product/core/model/base_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | abstract class BaseModel extends Equatable { 4 | const BaseModel(); 5 | 6 | Map toJson(); 7 | T fromJson(dynamic json); 8 | } 9 | -------------------------------------------------------------------------------- /lib/product/core/model/base_response_model.dart: -------------------------------------------------------------------------------- 1 | abstract class BaseResponseModel { 2 | BaseResponseModel(); 3 | } 4 | -------------------------------------------------------------------------------- /lib/product/core/model/firestore_model.dart: -------------------------------------------------------------------------------- 1 | final class FirestoreModel { 2 | final bool? isSuccess; 3 | final String? error; 4 | final T? data; 5 | 6 | FirestoreModel({this.isSuccess, this.error, this.data}); 7 | } 8 | 9 | final class OtherFirestoreModel { 10 | final bool isSuccess; 11 | final String error; 12 | final T data; 13 | 14 | OtherFirestoreModel({ 15 | required this.isSuccess, 16 | required this.error, 17 | required this.data, 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /lib/product/core/model/response_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:tutorial_app/product/core/model/base_model.dart'; 2 | 3 | import 'base_response_model.dart'; 4 | 5 | /// [ResponseModel] sınıfı, [BaseResponseModel] sınıfından türetilmiş bir sınıftır. 6 | /// Bu sınıf, response modelleri için kullanılır. 7 | /// [T] tipinde bir data alır ve [ServiceManager] da kullandığı amaca göre düzenlenir. 8 | /// [T] tipi [BaseModel] sınıfından türetilmiş bir sınıf olmalıdır. 9 | /// [BaseModel] Sınıfı içeriğinde, [fromJson] metodu bulunmalıdır. 10 | /// Bu metot, API'den gelen veriyi parse eder. 11 | final class ResponseModel extends BaseResponseModel { 12 | ResponseModel({this.data, this.statusCode, this.message}); 13 | final T? data; 14 | final int? statusCode; 15 | final String? message; 16 | } 17 | -------------------------------------------------------------------------------- /lib/product/core/service/dio_service_manager.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | import 'package:dio/dio.dart'; 4 | import 'package:tutorial_app/product/core/model/base_model.dart'; 5 | import 'package:tutorial_app/product/core/model/response_model.dart'; 6 | import 'package:tutorial_app/product/core/service/iservice_manager.dart'; 7 | 8 | final class DioServiceManager extends IServiceManager { 9 | DioServiceManager({required this.baseUrl}) { 10 | _dio = Dio(BaseOptions(baseUrl: baseUrl, headers: _headers)); 11 | } 12 | 13 | final _headers = { 14 | 'Content-Type': 'application/json', 15 | }; 16 | 17 | late Dio _dio; 18 | final String baseUrl; 19 | @override 20 | Future> get(String path, 21 | {required T model}) async { 22 | final Response response; 23 | 24 | try { 25 | response = await _dio.get('$baseUrl$path'); 26 | 27 | /// [response.statusCode] 200(HttpStatus.ok) değilse, hata döner. 28 | if (response.statusCode != HttpStatus.ok) { 29 | return ResponseModel( 30 | message: response.statusMessage, statusCode: response.statusCode); 31 | } 32 | final encodedData = json.encode(response.data); 33 | final parsedModel = model.fromJson(encodedData); 34 | return ResponseModel(data: parsedModel, statusCode: response.statusCode); 35 | } on DioException catch (e) { 36 | return ResponseModel(message: e.message); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/product/core/service/iservice_manager.dart: -------------------------------------------------------------------------------- 1 | import '../model/base_model.dart'; 2 | import '../model/response_model.dart'; 3 | 4 | abstract class IServiceManager { 5 | Future> get( 6 | String path, { 7 | /// [T] tipi model parametresi parse edilecek verinin tipini belirtir. 8 | required T model, 9 | }); 10 | } 11 | -------------------------------------------------------------------------------- /lib/product/core/starter/starter.dart: -------------------------------------------------------------------------------- 1 | import 'package:firebase_core/firebase_core.dart'; 2 | import 'package:firebase_crashlytics/firebase_crashlytics.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:tutorial_app/product/utils/cache/cache_manager.dart'; 5 | import 'package:tutorial_app/product/utils/getit/product_state_container.dart'; 6 | import 'package:tutorial_app/product/utils/localization/localization_manager.dart'; 7 | import 'package:tutorial_app/product/utils/remote_config/remote_config_manager.dart'; 8 | 9 | import '../../../firebase_options.dart'; 10 | import '../../utils/shared/shared_manager.dart'; 11 | 12 | /// [Starter] sınıfı, uygulama başlatıldığında çalıştırılması gereken işlemleri yönetir. 13 | final class Starter { 14 | /// [Starter] sınıfının yapıcı metodu. 15 | /// bu sınıfın yapıcı metodu private olarak tanımlanmıştır. 16 | /// bu sınıftan nesne oluşturulmasını engeller. 17 | Starter._(); 18 | 19 | /// [init] metodu, uygulama başlatıldığında çalıştırılması gereken metoddur. 20 | /// bu metot, uygulamanın içerisinde kullanılacak olan özelliklerin başlatılmasını sağlar. 21 | /// Burada ki işlemler sırasıyla yapılmalıdır, bu yüzden bu metot [async] olarak tanımlanmıştır. 22 | /// [await] ile beklenmesi gereken işlemler belirtilir. 23 | static Future init() async { 24 | /// [WidgetsFlutterBinding.ensureInitialized] metodu, uygulamanın başlatılmasını sağlar. 25 | /// Bu metot, uygulamanın başlatılmasını sağlamak için kullanılır. 26 | /// Bu metot, uygulama başlatılmadan önce çalıştırılmalıdır. 27 | WidgetsFlutterBinding.ensureInitialized(); 28 | 29 | /// Firebase servislerinin başlatılması için [Firebase.initializeApp] metodu çalıştırılır. 30 | /// FirebaseCore paketinin [initializeApp] metodu, Firebase servislerini başlatır. 31 | await Firebase.initializeApp( 32 | options: DefaultFirebaseOptions.currentPlatform, 33 | ); 34 | 35 | FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError; 36 | 37 | await RemoteConfigManager.init(); 38 | await RemoteConfigManager.fetchAndActivate(); 39 | 40 | /// [LocalizationManager] sınıfının [init] metodu çalıştırılır. 41 | await LocalizationManager.init(); 42 | 43 | /// [SharedManager] sınıfının [init] metodu çalıştırılır. 44 | await SharedManager.init(); 45 | await CacheManager.init(); 46 | ProductStateContainer.setup(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/product/utils/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/lib/product/utils/.DS_Store -------------------------------------------------------------------------------- /lib/product/utils/cache/mixin/cache_auth_mixin.dart: -------------------------------------------------------------------------------- 1 | part of '../cache_manager.dart'; 2 | 3 | mixin CacheAuthMixin { 4 | /// [saveToken] metodu [String] tipinde bir token alır ve 5 | /// bu tokenı [PreferenceKey.token] anahtarına kaydeder. 6 | /// 7 | /// Token kaydedilirse true döner. 8 | /// Token kaydedilemezse false döner. 9 | Future saveToken(String token) async { 10 | return CacheManager.instance.setData(token, PreferenceKey.token); 11 | } 12 | 13 | /// [getToken] metodu [String] tipinde bir token döner. 14 | /// 15 | /// Token dönerse [String] tipinde token döner. 16 | /// Token dönemezse null döner. 17 | Future getToken() async { 18 | return CacheManager.instance.getData(PreferenceKey.token); 19 | } 20 | 21 | /// [deleteToken] metodu 22 | /// [String] tipinde bir token alır ve 23 | /// bu tokenı siler. 24 | /// 25 | /// Token silinirse true döner. 26 | /// Token silinemezse false döner. 27 | Future deleteToken() async { 28 | return CacheManager.instance.clearData(PreferenceKey.token); 29 | } 30 | 31 | Future getUserId() async { 32 | return CacheManager.instance.getData(PreferenceKey.userId); 33 | } 34 | 35 | Future saveUserId(String userId) async { 36 | return CacheManager.instance.setData(userId, PreferenceKey.userId); 37 | } 38 | 39 | Future deleteUserId() async { 40 | return CacheManager.instance.clearData(PreferenceKey.userId); 41 | } 42 | 43 | Future saveOtpToken(String token) async { 44 | return CacheManager.instance.setData(token, PreferenceKey.otpToken); 45 | } 46 | 47 | Future getOtpToken() async { 48 | return CacheManager.instance.getData(PreferenceKey.otpToken); 49 | } 50 | 51 | Future deleteOtpToken() async { 52 | return CacheManager.instance.clearData(PreferenceKey.otpToken); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/product/utils/cache/mixin/cache_models_mixin.dart: -------------------------------------------------------------------------------- 1 | part of '../cache_manager.dart'; 2 | 3 | mixin CacheModelsMixin { 4 | /// [saveLoginModelToList] metodu [LoginRequestModel] 5 | /// tipinde bir model alır ve 6 | /// bu modeli [List] tipinde bir listeye ekler. 7 | /// 8 | /// Model eklenirse true döner. 9 | /// Model eklenemezse false döner. 10 | Future saveLoginModelToList(LoginRequestModel model) async { 11 | final email = model.email; 12 | if (email == null) return false; 13 | final loginModelList = await getLoginModelList(); 14 | if (loginModelList == null) { 15 | return CacheManager.instance.setDataList([ 16 | jsonEncode(model.toJson()), 17 | ], PreferenceKey.loginModel); 18 | } 19 | if (loginModelList.any((element) => element.email == email)) { 20 | loginModelList.removeWhere((element) => element.email == email); 21 | } 22 | loginModelList.add(model); 23 | final jsonData = loginModelList.map((e) => jsonEncode(e.toJson())).toList(); 24 | await CacheManager.instance.clearData(PreferenceKey.loginModel); 25 | return CacheManager.instance.setDataList( 26 | jsonData, 27 | PreferenceKey.loginModel, 28 | ); 29 | } 30 | 31 | /// [deleteLoginModelFromList] metodu 32 | /// [String] tipinde bir kullanıcı adı alır ve 33 | /// bu kullanıcı adına sahip olan [LoginRequestModel] tipindeki modeli siler. 34 | /// 35 | /// Model silinirse true döner. 36 | /// Model silinemezse false döner. 37 | Future deleteLoginModelFromList(String email) async { 38 | final data = await getLoginModelList(); 39 | if (data == null) return false; 40 | 41 | data.removeWhere((element) => element.email == email); 42 | final jsonData = data.map((e) => jsonEncode(e.toJson())).toList(); 43 | await CacheManager.instance.clearData(PreferenceKey.loginModel); 44 | return CacheManager.instance.setDataList( 45 | jsonData, 46 | PreferenceKey.loginModel, 47 | ); 48 | } 49 | 50 | /// [getLoginModelList] metodu 51 | /// [List] tipinde bir liste döner. 52 | /// 53 | /// Liste dönerse [List] tipinde liste döner. 54 | /// Liste dönemezse null döner. 55 | /// 56 | /// Verilerin tipi [List] olduğu için 57 | /// [List] tipine dönüştürülür. 58 | Future?> getLoginModelList() async { 59 | final data = CacheManager.instance.getDataList(PreferenceKey.loginModel); 60 | if (data == null) return null; 61 | try { 62 | final loginModelList = 63 | data 64 | .map( 65 | (e) => LoginRequestModel.fromJson( 66 | jsonDecode(e) as Map, 67 | ), 68 | ) 69 | .cast() 70 | .toList(); 71 | return loginModelList; 72 | } catch (e) { 73 | await CacheManager.instance.clearData(PreferenceKey.loginModel); 74 | return null; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/product/utils/cache/mixin/cache_repository_mixin.dart: -------------------------------------------------------------------------------- 1 | part of '../cache_manager.dart'; 2 | 3 | mixin CacheRepositoryMixin { 4 | Future saveFcmToken(String token) async { 5 | return CacheManager.instance.setData(token, PreferenceKey.fcmToken); 6 | } 7 | 8 | String? getFcmToken() { 9 | return CacheManager.instance.getData(PreferenceKey.fcmToken); 10 | } 11 | 12 | // Delete FCM token 13 | Future deleteFcmToken() async { 14 | return CacheManager.instance.clearData(PreferenceKey.fcmToken); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/product/utils/cache/preference_key.dart: -------------------------------------------------------------------------------- 1 | enum PreferenceKey { 2 | userModel, 3 | loginModel, 4 | schduleModel, 5 | token, 6 | otpToken, 7 | fcmToken, 8 | language, 9 | theme, 10 | onBoarding, 11 | userId, 12 | } 13 | -------------------------------------------------------------------------------- /lib/product/utils/getit/product_state_container.dart: -------------------------------------------------------------------------------- 1 | import 'package:get_it/get_it.dart'; 2 | import 'package:tutorial_app/feature/home/service/home_service.dart'; 3 | import 'package:tutorial_app/feature/photos/service/photos_service.dart'; 4 | import 'package:tutorial_app/product/core/service/dio_service_manager.dart'; 5 | import 'package:tutorial_app/product/core/service/service_manager.dart'; 6 | import 'package:tutorial_app/product/utils/cache/cache_manager.dart'; 7 | import 'package:tutorial_app/product/utils/shared/shared_manager.dart'; 8 | 9 | import '../remote_config/remote_config_manager.dart'; 10 | 11 | abstract class ProductStateContainer { 12 | static final _getIt = GetIt.instance; 13 | 14 | static void setup() { 15 | _getIt 16 | ..registerSingleton(RemoteConfigManager.remoteConfig) 17 | ..registerLazySingleton(() async => await SharedManager.initInstance()) 18 | ..registerFactory(() => HomeService(_getIt.get( 19 | param1: 'https://jsonplaceholder.typicode.com/'))) 20 | ..registerFactory(() => PhotosService(_getIt.get( 21 | param1: 'https://api.slingacademy.com/v1/sample-data/'))) 22 | ..registerFactoryParam( 23 | (param1, param2) => DioServiceManager(baseUrl: param1)) 24 | ..registerFactoryParam( 25 | (param1, param2) => ServiceManager(param1)) 26 | ..registerSingleton(CacheManager.instance); 27 | } 28 | 29 | static void setupForTest() { 30 | _getIt 31 | ..registerFactory(() => HomeService(_getIt.get( 32 | param1: 'https://jsonplaceholder.typicode.com/'))) 33 | ..registerFactory(() => PhotosService(_getIt.get( 34 | param1: 'https://api.slingacademy.com/v1/sample-data/'))) 35 | ..registerFactoryParam( 36 | (param1, param2) => DioServiceManager(baseUrl: param1)) 37 | ..registerFactoryParam( 38 | (param1, param2) => ServiceManager(param1)) 39 | ..registerSingleton(CacheManager.instance); 40 | } 41 | 42 | static T get() => _getIt.get(); 43 | } 44 | -------------------------------------------------------------------------------- /lib/product/utils/getit/product_state_items.dart: -------------------------------------------------------------------------------- 1 | import 'package:tutorial_app/feature/home/service/home_service.dart'; 2 | import 'package:tutorial_app/feature/photos/service/photos_service.dart'; 3 | import 'package:tutorial_app/product/utils/cache/cache_manager.dart'; 4 | import 'package:tutorial_app/product/utils/getit/product_state_container.dart'; 5 | import 'package:tutorial_app/product/utils/remote_config/remote_config_manager.dart'; 6 | import 'package:tutorial_app/product/utils/shared/shared_manager.dart'; 7 | 8 | final class ProductStateItems { 9 | static RemoteConfigManager get remoteConfig => 10 | ProductStateContainer.get(); 11 | static SharedManager get sharedManager => 12 | ProductStateContainer.get(); 13 | static HomeService get homeService => 14 | ProductStateContainer.get(); 15 | static PhotosService get photoService => 16 | ProductStateContainer.get(); 17 | static CacheManager get cacheManager => 18 | ProductStateContainer.get(); 19 | } 20 | -------------------------------------------------------------------------------- /lib/product/utils/remote_config/remote_config_manager.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:firebase_remote_config/firebase_remote_config.dart'; 4 | 5 | /// [RemoteConfigManager] sınıfı Firebase Remote Config servisini kullanarak 6 | /// uygulama içerisindeki remote config verilerine erişim sağlar. 7 | /// Bu sınıf ile gizli bilgilerin uygulama içerisinde tutulmadan kullanılmasını 8 | /// yada uygulama içerisindeki sabit verilerin dinamik olarak değiştirilmesi sağlanır. 9 | final class RemoteConfigManager { 10 | /// [remoteConfig] değişkeni Firebase Remote Config servisini kullanmak için 11 | /// oluşturulmuş bir değişkendir. 12 | /// Bu değişken üzerinden remote config verilerine erişim sağlanır. 13 | static final remoteConfig = FirebaseRemoteConfig.instance; 14 | 15 | /// [init] metodu ile remote config servisi başlatılır. 16 | /// Bu metodun çağrılması ile remote config servisi kullanıma hazır hale gelir. 17 | /// Bu metodun çağrılması uygulama başlatıldığında yapılmalıdır. 18 | static Future init() async { 19 | /// Remote Config ayarları yapılır. 20 | /// Bu ayarlar ile remote config servisi ne kadar sürede bir veri çekeceği 21 | /// ve minimum ne kadar sürede bir veri çekileceği belirlenir. 22 | await remoteConfig.setConfigSettings(RemoteConfigSettings( 23 | fetchTimeout: const Duration(minutes: 1), 24 | minimumFetchInterval: const Duration(minutes: 1), 25 | )); 26 | } 27 | 28 | /// [fetchAndActivate] metodu ile remote config servisinden veri çekilir ve 29 | /// bu veri kullanıma hazır hale getirilir. 30 | static Future fetchAndActivate() async { 31 | await remoteConfig.fetchAndActivate(); 32 | } 33 | 34 | /// [getString] metodu ile remote config servisinden string tipinde veri çekilir. 35 | static String getString(String key) { 36 | final reponse = remoteConfig.getString(key); 37 | return reponse; 38 | } 39 | 40 | /// [getInt] metodu ile remote config servisinden string tipinde veri çekilir. 41 | static int getInt(String key) { 42 | final reponse = remoteConfig.getInt(key); 43 | return reponse; 44 | } 45 | 46 | /// [getBool] metodu ile remote config servisinden bool tipinde veri çekilir. 47 | static bool getBool(String key) { 48 | final reponse = remoteConfig.getBool(key); 49 | return reponse; 50 | } 51 | 52 | static Map getAll(String key) { 53 | final reponse = remoteConfig.getAll(); 54 | return reponse; 55 | } 56 | 57 | /// [setDefaults] metodu ile remote config servisi için varsayılan değerler 58 | /// belirlenir. 59 | Future setDefaults(Map defaults) async { 60 | await remoteConfig.setDefaults(defaults); 61 | } 62 | 63 | /// [onConfigChanged] metodu ile remote config servisindeki verilerin değişip 64 | /// değişmediği dinlenir. 65 | /// Bu metodu StreamBuilder ile kullanabilirsiniz 66 | /// örnek: 67 | /// ``` 68 | /// StreamBuilder( 69 | /// stream: RemoteConfigManager.onConfigChanged, 70 | /// builder: (context, snapshot) { 71 | /// return Container(); 72 | /// }, 73 | /// ); 74 | /// ``` 75 | static Stream get onConfigChanged => 76 | remoteConfig.onConfigUpdated; 77 | } 78 | -------------------------------------------------------------------------------- /lib/product/utils/router/adaptive_page_builder.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | /// [AdaptivePageBuilder] sınıfı, uygulama içerisinde kullanılacak olan sayfa builder'ıdır. 6 | /// [builder] metodu ile geriye [Page] tipinde bir nesne döndürür. 7 | /// Bu nesnenin tipi, platforma göre değişir. 8 | /// Eğer platform iOS ise [CupertinoPage] tipinde bir nesne döndürür. 9 | /// Eğer platform Android ise [MaterialPage] tipinde bir nesne döndürür. 10 | /// Bu sayede uygulama içerisinde kullanılacak olan sayfa builder'ı platforma göre değişir. 11 | final class AdaptivePageBuilder { 12 | AdaptivePageBuilder._(); 13 | 14 | /// [builder] metodu, platforma göre sayfa builder'ı döndürür. 15 | static Page builder({ 16 | required Widget child, 17 | }) { 18 | if (Platform.isIOS || Platform.isMacOS) { 19 | return CupertinoPage( 20 | child: child, 21 | ); 22 | } 23 | return MaterialPage( 24 | child: child, 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/product/utils/router/route_params.dart: -------------------------------------------------------------------------------- 1 | /// [RouteParams] enum sınıfı bir sayfa yolu içerisinde kullanılacak olan parametrelerin isimlerini içerir. 2 | /// Parametrelerin isimleri sadece burada belirlendiği için yazım hatalarının önüne geçilir. 3 | enum RouteParams { 4 | user('user'), 5 | ; 6 | 7 | const RouteParams(this.param); 8 | final String param; 9 | } 10 | -------------------------------------------------------------------------------- /lib/product/utils/router/route_paths.dart: -------------------------------------------------------------------------------- 1 | /// [RoutePaths] enum sınıfı, GoRouter paketi içerisinde kullanılacak olan sayfa yollarını içerir. 2 | /// Her bir sayfa yolu, bir string değerine sahiptir. 3 | /// Bu sayede sayfa yolları, uygulama içerisinde kullanılacak olan sayfa builder'larına verilebilir. 4 | /// Bu değerler burada verildiği için yazım hatalarının önüne geçilir. 5 | enum RoutePaths { 6 | initial('/'), 7 | userDetail('/user-detail'), 8 | login('/login'), 9 | register('/register'), 10 | ; 11 | 12 | const RoutePaths(this.path); 13 | final String path; 14 | } 15 | -------------------------------------------------------------------------------- /lib/product/utils/router/router_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:go_router/go_router.dart'; 2 | import 'package:tutorial_app/feature/auth/login/view/login_view.dart'; 3 | import 'package:tutorial_app/feature/splash/view/splash_view.dart'; 4 | import 'package:tutorial_app/product/utils/router/adaptive_page_builder.dart'; 5 | import 'package:tutorial_app/product/utils/router/route_paths.dart'; 6 | 7 | import '../../../feature/auth/register/view/register_view.dart'; 8 | import '../../../feature/home/model/user_model.dart'; 9 | import '../../../feature/home/view/user_detail_view.dart'; 10 | 11 | /// [RouterManager] sınıfı, uygulama içerisinde kullanılacak olan sayfa yollarını içerir. 12 | /// Bu sınıf, GoRouter paketi içerisinde kullanılacak olan sayfa builder'ları içerir. 13 | /// Bu sayede uygulama içerisinde kullanılacak olan sayfa builder'ları tek bir yerde toplanmış olur. 14 | final class RouterManager { 15 | RouterManager._(); 16 | 17 | /// [routes] getter metodu, uygulama içerisinde kullanılacak olan sayfa builder'ları döndürür. 18 | static GoRouter get routes => _routes; 19 | 20 | /// [_routes] değişkeni, uygulama içerisinde kullanılacak olan sayfa builder'ları içerir. 21 | /// Bu değişken, [GoRouter] tipinde bir nesnedir. 22 | /// private olarak tanımlandığı için, bu değişken sadece bu sınıf içerisinde kullanılabilir. 23 | static final _routes = GoRouter( 24 | routes: [ 25 | GoRoute( 26 | /// [path] parametresi, sayfa yolu içerir. 27 | /// enum olarak kullanılmasının sebebi, yazım hatalarının önüne geçilmesidir. 28 | /// Bu sayede sayfa yolları, uygulama içerisinde aynı şekilde kullanılabilir. 29 | path: RoutePaths.initial.path, 30 | pageBuilder: (context, state) => AdaptivePageBuilder.builder( 31 | child: const SplashView(), 32 | ), 33 | ), 34 | GoRoute( 35 | path: RoutePaths.userDetail.path, 36 | pageBuilder: (context, state) => AdaptivePageBuilder.builder( 37 | child: UserDetailView(user: state.extra as UserModel), 38 | ), 39 | ), 40 | GoRoute( 41 | path: RoutePaths.login.path, 42 | pageBuilder: (context, state) => AdaptivePageBuilder.builder( 43 | child: const LoginView(), 44 | ), 45 | ), 46 | GoRoute( 47 | path: RoutePaths.register.path, 48 | pageBuilder: (context, state) => AdaptivePageBuilder.builder( 49 | child: const RegisterView(), 50 | ), 51 | ), 52 | ], 53 | ); 54 | } 55 | -------------------------------------------------------------------------------- /lib/product/utils/theme/color_schemes.g.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | const lightColorScheme = ColorScheme( 4 | brightness: Brightness.light, 5 | primary: Color(0xFF00629F), 6 | onPrimary: Color(0xFFFFFFFF), 7 | primaryContainer: Color(0xFFD0E4FF), 8 | onPrimaryContainer: Color(0xFF001D34), 9 | secondary: Color(0xFF526070), 10 | onSecondary: Color(0xFFFFFFFF), 11 | secondaryContainer: Color(0xFFD6E4F7), 12 | onSecondaryContainer: Color(0xFF0F1D2A), 13 | tertiary: Color(0xFF695779), 14 | onTertiary: Color(0xFFFFFFFF), 15 | tertiaryContainer: Color(0xFFF0DBFF), 16 | onTertiaryContainer: Color(0xFF241532), 17 | error: Color(0xFFBA1A1A), 18 | errorContainer: Color(0xFFFFDAD6), 19 | onError: Color(0xFFFFFFFF), 20 | onErrorContainer: Color(0xFF410002), 21 | background: Color(0xFFFCFCFF), 22 | onBackground: Color(0xFF1A1C1E), 23 | outline: Color(0xFF73777F), 24 | onInverseSurface: Color(0xFFF1F0F4), 25 | inverseSurface: Color(0xFF2F3033), 26 | inversePrimary: Color(0xFF9BCBFF), 27 | shadow: Color(0xFF000000), 28 | surfaceTint: Color(0xFF00629F), 29 | outlineVariant: Color(0xFFC2C7CF), 30 | scrim: Color(0xFF000000), 31 | surface: Color(0xFFF9F9FC), 32 | onSurface: Color(0xFF1A1C1E), 33 | surfaceVariant: Color(0xFFDEE3EB), 34 | onSurfaceVariant: Color(0xFF42474E), 35 | ); 36 | 37 | const darkColorScheme = ColorScheme( 38 | brightness: Brightness.dark, 39 | primary: Color(0xFF9BCBFF), 40 | onPrimary: Color(0xFF003256), 41 | primaryContainer: Color(0xFF004A79), 42 | onPrimaryContainer: Color(0xFFD0E4FF), 43 | secondary: Color(0xFFBAC8DB), 44 | onSecondary: Color(0xFF243240), 45 | secondaryContainer: Color(0xFF3B4857), 46 | onSecondaryContainer: Color(0xFFD6E4F7), 47 | tertiary: Color(0xFFD5BEE5), 48 | onTertiary: Color(0xFF3A2A48), 49 | tertiaryContainer: Color(0xFF514060), 50 | onTertiaryContainer: Color(0xFFF0DBFF), 51 | error: Color(0xFFFFB4AB), 52 | errorContainer: Color(0xFF93000A), 53 | onError: Color(0xFF690005), 54 | onErrorContainer: Color(0xFFFFDAD6), 55 | background: Color(0xFF1A1C1E), 56 | onBackground: Color(0xFFE2E2E6), 57 | outline: Color(0xFF8C9199), 58 | onInverseSurface: Color(0xFF1A1C1E), 59 | inverseSurface: Color(0xFFE2E2E6), 60 | inversePrimary: Color(0xFF00629F), 61 | shadow: Color(0xFF000000), 62 | surfaceTint: Color(0xFF9BCBFF), 63 | outlineVariant: Color(0xFF42474E), 64 | scrim: Color(0xFF000000), 65 | surface: Color(0xFF121316), 66 | onSurface: Color(0xFFC6C6CA), 67 | surfaceVariant: Color(0xFF42474E), 68 | onSurfaceVariant: Color(0xFFC2C7CF), 69 | ); 70 | -------------------------------------------------------------------------------- /lib/product/utils/theme/theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:google_fonts/google_fonts.dart'; 3 | import 'package:tutorial_app/product/utils/theme/color_schemes.g.dart'; 4 | 5 | ThemeData lightTheme = ThemeData( 6 | fontFamily: GoogleFonts.ubuntu().fontFamily, 7 | useMaterial3: true, 8 | colorScheme: lightColorScheme, 9 | ); 10 | ThemeData darkTheme = ThemeData( 11 | fontFamily: GoogleFonts.ubuntu().fontFamily, 12 | useMaterial3: true, 13 | colorScheme: darkColorScheme, 14 | ); 15 | 16 | extension type const ChooseThemeMode(String themeMode) { 17 | ThemeMode get getThemeMode => switch (themeMode) { 18 | 'light' => ThemeMode.light, 19 | 'dark' => ThemeMode.dark, 20 | _ => ThemeMode.system, 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /lib/product/widgets/maps/_apple_maps_widget.dart: -------------------------------------------------------------------------------- 1 | part of 'maps_view.dart'; 2 | 3 | /// Apple Map Widget 4 | /// Bu widget, Google Maps yerine Apple Maps kullanmak isteyenler için 5 | /// Yada Apple için farklı bir map kullanılabilir. 6 | final class _AppleMapWidget extends StatelessWidget { 7 | _AppleMapWidget({required this.latitude, required this.longitude}); 8 | final double latitude; 9 | final double longitude; 10 | final _controller = Completer(); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return GoogleMap( 15 | initialCameraPosition: CameraPosition( 16 | target: LatLng(latitude, longitude), 17 | zoom: 15, 18 | ), 19 | onMapCreated: (controller) { 20 | _controller.complete(controller); 21 | }, 22 | markers: { 23 | Marker( 24 | markerId: const MarkerId('1'), 25 | position: LatLng(latitude, longitude), 26 | ), 27 | }, 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/product/widgets/maps/_google_maps_widget.dart: -------------------------------------------------------------------------------- 1 | part of 'maps_view.dart'; 2 | 3 | class _GoogleMapWidget extends StatelessWidget { 4 | _GoogleMapWidget({required this.latitude, required this.longitude}); 5 | final double latitude; 6 | final double longitude; 7 | final _controller = Completer(); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return GoogleMap( 12 | initialCameraPosition: CameraPosition( 13 | target: LatLng(latitude, longitude), 14 | zoom: 15, 15 | ), 16 | onMapCreated: (controller) { 17 | _controller.complete(controller); 18 | }, 19 | markers: { 20 | Marker( 21 | markerId: const MarkerId('1'), 22 | position: LatLng(latitude, longitude), 23 | ), 24 | }, 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/product/widgets/maps/maps_view.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:google_maps_flutter/google_maps_flutter.dart'; 6 | 7 | part '_google_maps_widget.dart'; 8 | part '_apple_maps_widget.dart'; 9 | 10 | /// Bu widget harita gösterimi için kullanılır. 11 | /// [latitude] ve [longitude] parametreleri haritanın gösterileceği konumu belirtir. 12 | /// [title] parametresi sayfa başlığını belirtir. 13 | /// [latitude], [longitude] ve [title] parametreleri zorunludur. 14 | /// Bu sebeple required olarak belirtilmiştir. 15 | /// [_GoogleMapWidget] ve [_AppleMapWidget] widget'ları platforma göre farklılık gösterir. 16 | /// Bu sebeple [Platform] sınıfı kullanılarak platform kontrolü yapılır. 17 | /// Platforma göre uygun widget döner. 18 | /// Platform kontrolü için [Builder] widget'ı kullanılır. 19 | /// Hiçbir platforma uygun değilse, desteklenmeyen platform uyarısı döner. 20 | /// [_GoogleMapWidget] ve [_AppleMapWidget] widget'ları dışarıdan erişim olmaması için 21 | /// _(private) ile başlar ve part olarak ayrı dosyalarda tanımlanmıştır. 22 | /// Bu widget'lar sadece bu dosyada kullanılır. 23 | /// [_AppleMapWidget] örnek olarak eklenmiştir, onun yerine Huawei Map, Yandex Map gibi 24 | /// farklı bir map kullanılabilir, farklı cihazlar ve platformlar için. 25 | final class MapsView extends StatelessWidget { 26 | const MapsView({ 27 | super.key, 28 | required this.latitude, 29 | required this.longitude, 30 | required this.title, 31 | }); 32 | final double latitude; 33 | final double longitude; 34 | final String title; 35 | 36 | @override 37 | Widget build(BuildContext context) { 38 | return Scaffold( 39 | appBar: AppBar( 40 | title: Text(title), 41 | ), 42 | body: Builder( 43 | builder: (context) { 44 | if (Platform.isAndroid) { 45 | return _GoogleMapWidget(latitude: latitude, longitude: longitude); 46 | } else if (Platform.isIOS) { 47 | return _AppleMapWidget(latitude: latitude, longitude: longitude); 48 | } 49 | return const Center( 50 | child: Text('Unsupported platform for Map.'), 51 | ); 52 | }, 53 | ), 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/product/widgets/shimmer/custom_image_shimmer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:shimmer/shimmer.dart'; 3 | 4 | final class CustomImageShimmer extends StatelessWidget { 5 | const CustomImageShimmer({super.key}); 6 | 7 | @override 8 | Widget build(BuildContext context) { 9 | return Shimmer.fromColors( 10 | baseColor: const Color.fromARGB(255, 193, 193, 193), 11 | highlightColor: Colors.white, 12 | child: GridView.builder( 13 | itemCount: 10, 14 | gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( 15 | crossAxisCount: 2, 16 | ), 17 | itemBuilder: (context, index) { 18 | return Container( 19 | margin: const EdgeInsets.all(8), 20 | decoration: BoxDecoration( 21 | color: Colors.grey, 22 | borderRadius: BorderRadius.circular(8), 23 | ), 24 | ); 25 | }, 26 | ), 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/product/widgets/shimmer/custom_list_shimmer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:shimmer/shimmer.dart'; 3 | 4 | class CustomListShimmer extends StatelessWidget { 5 | const CustomListShimmer({super.key}); 6 | 7 | @override 8 | Widget build(BuildContext context) { 9 | return Shimmer.fromColors( 10 | baseColor: const Color.fromARGB(255, 193, 193, 193), 11 | highlightColor: Colors.white, 12 | child: ListView.builder( 13 | itemCount: 10, 14 | itemBuilder: (context, index) { 15 | return Card( 16 | child: ListTile( 17 | title: Container( 18 | color: Colors.grey, 19 | height: 20, 20 | ), 21 | subtitle: Container( 22 | color: Colors.grey, 23 | height: 20, 24 | ), 25 | trailing: Container( 26 | color: Colors.grey, 27 | height: 20, 28 | width: 20, 29 | ), 30 | ), 31 | ); 32 | }, 33 | ), 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/product/widgets/text/custom_text.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class CustomText extends StatelessWidget { 4 | const CustomText(this.data, {super.key}); 5 | final String data; 6 | 7 | @override 8 | Widget build(BuildContext context) { 9 | return Text(data); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/product/widgets/text_field/custom_text_field.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_form_builder/flutter_form_builder.dart'; 3 | import 'package:form_builder_validators/form_builder_validators.dart'; 4 | 5 | final class CustomTextField extends StatelessWidget { 6 | const CustomTextField({ 7 | required this.controller, 8 | required this.name, 9 | required this.label, 10 | this.obscureText = false, 11 | required this.validators, 12 | super.key, 13 | }); 14 | final TextEditingController controller; 15 | final String name; 16 | final String label; 17 | final bool obscureText; 18 | final List validators; 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | return FormBuilderTextField( 23 | name: name, 24 | controller: controller, 25 | obscureText: obscureText, 26 | decoration: 27 | InputDecoration(labelText: label, border: const OutlineInputBorder()), 28 | validator: FormBuilderValidators.compose(validators), 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /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.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 cloud_firestore 9 | import firebase_analytics 10 | import firebase_auth 11 | import firebase_core 12 | import firebase_crashlytics 13 | import firebase_remote_config 14 | import path_provider_foundation 15 | import shared_preferences_foundation 16 | 17 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 18 | FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) 19 | FLTFirebaseAnalyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAnalyticsPlugin")) 20 | FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) 21 | FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) 22 | FLTFirebaseCrashlyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCrashlyticsPlugin")) 23 | FLTFirebaseRemoteConfigPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseRemoteConfigPlugin")) 24 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 25 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 26 | } 27 | -------------------------------------------------------------------------------- /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.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /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 | @main 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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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 = tutorial_app 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.efestech.tutorialApp 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2024 com.efestech. 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 Cocoa 2 | import FlutterMacOS 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 | -------------------------------------------------------------------------------- /test/service/service_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:firebase_core/firebase_core.dart'; 4 | import 'package:flutter_test/flutter_test.dart'; 5 | import 'package:tutorial_app/feature/home/model/user_model.dart'; 6 | import 'package:tutorial_app/feature/home/service/home_service.dart'; 7 | import 'package:tutorial_app/feature/photos/model/photos.dart'; 8 | import 'package:tutorial_app/feature/photos/service/photos_service.dart'; 9 | import 'package:tutorial_app/product/utils/getit/product_state_container.dart'; 10 | import 'package:tutorial_app/product/utils/getit/product_state_items.dart'; 11 | 12 | void main() { 13 | late final HomeService homeService; 14 | late final PhotosService photosService; 15 | 16 | setUp(() async { 17 | ProductStateContainer.setupForTest(); 18 | homeService = ProductStateItems.homeService; 19 | photosService = ProductStateItems.photoService; 20 | }); 21 | 22 | test('Home Service', () async { 23 | final response = await homeService.getUsers(); 24 | 25 | expect(response.statusCode, HttpStatus.ok); 26 | expect(response.users, isNotNull); 27 | expect(response.users?.cast(), isNotEmpty); 28 | }); 29 | 30 | test('Photo Service', () async { 31 | final response = await photosService.getPhotos(10, 20); 32 | 33 | expect(response.statusCode, HttpStatus.ok); 34 | expect(response.photos, isNotNull); 35 | expect(response.photos?.photos?.cast(), isNotEmpty); 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /test/utils/snackbar_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:tutorial_app/product/utils/snackbar/custom_snackbar.dart'; 4 | 5 | void main() { 6 | testWidgets('Snackbar Test', (widgetTester) async { 7 | final button = ElevatedButton( 8 | onPressed: () => CustomSnackBar.showSnackBar(text: 'Hello World'), 9 | child: const Text('Show Snackbar'), 10 | ); 11 | 12 | await widgetTester.pumpWidget( 13 | MaterialApp( 14 | home: Scaffold( 15 | body: button, 16 | ), 17 | scaffoldMessengerKey: CustomSnackBar.messengerKey, 18 | ), 19 | ); 20 | 21 | await widgetTester.tap(find.byWidget(button)); 22 | await widgetTester.pumpAndSettle(); 23 | 24 | expect(find.byWidget(button), findsOneWidget); 25 | expect(find.text('Show Snackbar'), findsOneWidget); 26 | expect(find.text('Hello World'), findsOneWidget); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /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 in the flutter_test package. 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:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:tutorial_app/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/widgets/custom_text_field_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:tutorial_app/product/widgets/text_field/custom_text_field.dart'; 4 | 5 | void main() { 6 | testWidgets('CustomTextField Test', (widgetTester) async { 7 | final controller = TextEditingController(); 8 | final textField = CustomTextField( 9 | controller: controller, 10 | name: 'Test TextField', 11 | label: 'Test', 12 | validators: const []); 13 | 14 | await widgetTester.pumpWidget(MaterialApp( 15 | home: Scaffold( 16 | body: textField, 17 | ), 18 | )); 19 | 20 | await widgetTester.enterText(find.byWidget(textField), 'Hello World'); 21 | 22 | expect(find.text('Test'), findsOneWidget); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /test/widgets/custom_text_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:tutorial_app/product/widgets/text/custom_text.dart'; 4 | 5 | void main() { 6 | testWidgets('CustomText Test', (widgetTester) async { 7 | const text = CustomText('Hello World'); 8 | 9 | await widgetTester.pumpWidget(const MaterialApp( 10 | home: Scaffold( 11 | body: text, 12 | ), 13 | )); 14 | 15 | expect(find.text('Hello World'), findsOneWidget); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /test/widgets/profile_view_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:tutorial_app/feature/profile/model/profile_model.dart'; 4 | import 'package:tutorial_app/feature/profile/view/profile_view.dart'; 5 | 6 | void main() { 7 | testWidgets('Splash View Test', (widgetTester) async { 8 | const profile = ProfileField( 9 | userModel: ProfileModel( 10 | fullName: 'Alkan', 11 | email: 'alkanatas34@gmail.com', 12 | phoneNumber: '05467884453'), 13 | ); 14 | 15 | await widgetTester.pumpWidget(const MaterialApp( 16 | home: Scaffold( 17 | body: profile, 18 | ), 19 | )); 20 | 21 | expect(find.text('Alkan'), findsOneWidget); 22 | expect(find.text('alkanatas34@gmail.com'), findsOneWidget); 23 | expect(find.text('05467884453'), findsOneWidget); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /test/widgets/splash_view_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:tutorial_app/feature/splash/view/splash_view.dart'; 4 | 5 | void main() { 6 | testWidgets('Splash View Test', (widgetTester) async { 7 | const splash = SplashView(); 8 | 9 | await widgetTester.pumpWidget(const MaterialApp( 10 | home: Scaffold( 11 | body: splash, 12 | ), 13 | )); 14 | 15 | await widgetTester.tap(find.byIcon(Icons.home)); 16 | await widgetTester.tap(find.byIcon(Icons.image)); 17 | await widgetTester.tap(find.byIcon(Icons.person)); 18 | 19 | expect(find.byIcon(Icons.abc), findsOneWidget); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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 | tutorial_app 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tutorial_app", 3 | "short_name": "tutorial_app", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | void RegisterPlugins(flutter::PluginRegistry* registry) { 14 | CloudFirestorePluginCApiRegisterWithRegistrar( 15 | registry->GetRegistrarForPlugin("CloudFirestorePluginCApi")); 16 | FirebaseAuthPluginCApiRegisterWithRegistrar( 17 | registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); 18 | FirebaseCorePluginCApiRegisterWithRegistrar( 19 | registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); 20 | } 21 | -------------------------------------------------------------------------------- /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 | cloud_firestore 7 | firebase_auth 8 | firebase_core 9 | ) 10 | 11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 12 | ) 13 | 14 | set(PLUGIN_BUNDLED_LIBRARIES) 15 | 16 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 21 | endforeach(plugin) 22 | 23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 26 | endforeach(ffi_plugin) 27 | -------------------------------------------------------------------------------- /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.efestech" "\0" 93 | VALUE "FileDescription", "tutorial_app" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "tutorial_app" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2024 com.efestech. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "tutorial_app.exe" "\0" 98 | VALUE "ProductName", "tutorial_app" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"tutorial_app", 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/mrjake34/tutorial_app/ff8f3438f7525fa7e56a3a41603c2955bc41638f/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 | unsigned int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length == 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | --------------------------------------------------------------------------------