├── linux ├── .gitignore ├── main.cc ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt ├── my_application.h ├── my_application.cc └── CMakeLists.txt ├── .fvm ├── flutter_sdk └── fvm_config.json ├── ios ├── Runner │ ├── Runner-Bridging-Header.h │ ├── Assets.xcassets │ │ ├── LaunchImage.imageset │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ ├── README.md │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── 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-1024x1024@1x.png │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── Info.plist ├── Flutter │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── AppFrameworkInfo.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── WorkspaceSettings.xcsettings │ │ └── IDEWorkspaceChecks.plist ├── .gitignore ├── Podfile.lock └── Podfile ├── lib ├── src │ ├── core │ │ ├── constants.dart │ │ ├── widgets │ │ │ ├── loading_widget.dart │ │ │ ├── delete_item_dialog.dart │ │ │ ├── no_data_widget.dart │ │ │ ├── request_quote_row.dart │ │ │ └── estimate_form.dart │ │ ├── data_state.dart │ │ ├── styles.dart │ │ ├── providers.dart │ │ ├── form_validator.dart │ │ ├── app_router.dart │ │ └── data_state.freezed.dart │ ├── features │ │ ├── estimates │ │ │ ├── models │ │ │ │ ├── quote_model.dart │ │ │ │ ├── quote_model.g.dart │ │ │ │ └── quote_model.freezed.dart │ │ │ ├── services │ │ │ │ └── estimate_service.dart │ │ │ ├── controllers │ │ │ │ └── estimate_controller.dart │ │ │ └── views │ │ │ │ ├── estimate_form_view.dart │ │ │ │ └── estimates_vew.dart │ │ └── auth │ │ │ ├── models │ │ │ ├── user_model.g.dart │ │ │ ├── user_model.dart │ │ │ └── user_model.freezed.dart │ │ │ ├── controllers │ │ │ └── auth_controller.dart │ │ │ ├── services │ │ │ └── auth_service.dart │ │ │ └── views │ │ │ ├── login_view.dart │ │ │ └── register_view.dart │ └── app.dart └── main.dart ├── assets └── logo.png ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── manifest.json └── index.html ├── macos ├── Runner │ ├── Configs │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ ├── Warnings.xcconfig │ │ └── AppInfo.xcconfig │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ ├── app_icon_64.png │ │ │ ├── app_icon_1024.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Release.entitlements │ ├── MainFlutterWindow.swift │ ├── DebugProfile.entitlements │ └── Info.plist ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Runner.xcodeproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Podfile.lock └── Podfile ├── android ├── gradle.properties ├── app │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── launcher_icon.png │ │ │ │ ├── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable-v21 │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── values │ │ │ │ │ └── styles.xml │ │ │ │ └── values-night │ │ │ │ │ └── styles.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ ├── quote_request_app │ │ │ │ │ └── MainActivity.kt │ │ │ │ │ └── flutter_riverpod_app │ │ │ │ │ └── MainActivity.kt │ │ │ └── AndroidManifest.xml │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ └── profile │ │ │ └── AndroidManifest.xml │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle └── build.gradle ├── screenshots ├── estimates.jpg └── estimate-form.jpg ├── windows ├── runner │ ├── resources │ │ └── app_icon.ico │ ├── resource.h │ ├── utils.h │ ├── runner.exe.manifest │ ├── flutter_window.h │ ├── main.cpp │ ├── CMakeLists.txt │ ├── utils.cpp │ ├── flutter_window.cpp │ ├── Runner.rc │ ├── win32_window.h │ └── win32_window.cpp ├── .gitignore ├── flutter │ ├── generated_plugin_registrant.h │ ├── generated_plugin_registrant.cc │ ├── generated_plugins.cmake │ └── CMakeLists.txt └── CMakeLists.txt ├── README.md ├── pubspec.yaml ├── .gitignore ├── analysis_options.yaml └── .metadata /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /.fvm/flutter_sdk: -------------------------------------------------------------------------------- 1 | /home/gausoft/fvm/versions/3.0.4 -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /.fvm/fvm_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "flutterSdkVersion": "3.0.4", 3 | "flavors": {} 4 | } -------------------------------------------------------------------------------- /lib/src/core/constants.dart: -------------------------------------------------------------------------------- 1 | const String kBaseUrl = ''; 2 | const String kApiKey = ''; -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/assets/logo.png -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/web/icons/Icon-512.png -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | 5 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /screenshots/estimates.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/screenshots/estimates.jpg -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /screenshots/estimate-form.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/screenshots/estimate-form.jpg -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/android/app/src/main/res/mipmap-hdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/android/app/src/main/res/mipmap-mdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/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/gausoft/flutter-mvc-s-riverpod-example/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gausoft/flutter-mvc-s-riverpod-example/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/quote_request_app/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.quote_request_app 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/flutter_riverpod_app/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.flutter_riverpod_app 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | 4 | import 'src/app.dart'; 5 | 6 | void main() { 7 | runApp(const ProviderScope(child: QuoteRequestApp())); 8 | } 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 7 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/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 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.network.client 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | UrlLauncherWindowsRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 14 | } 15 | -------------------------------------------------------------------------------- /lib/src/core/widgets/loading_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class LoadingWidget extends StatelessWidget { 4 | const LoadingWidget({Key? key}) : super(key: key); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return const Center( 9 | child: SizedBox( 10 | width: 22, 11 | height: 22, 12 | child: CircularProgressIndicator(strokeWidth: 1.5), 13 | ), 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import path_provider_foundation 9 | import url_launcher_macos 10 | 11 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 12 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 13 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 14 | } 15 | -------------------------------------------------------------------------------- /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/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/core/data_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:freezed_annotation/freezed_annotation.dart'; 2 | 3 | part 'data_state.freezed.dart'; 4 | 5 | @freezed 6 | class DataState with _$DataState { 7 | const factory DataState.initial() = _Initial; 8 | const factory DataState.loading() = _Loading; 9 | const factory DataState.success({required T data}) = _Success; 10 | const factory DataState.error({ 11 | required String message, 12 | StackTrace? stackTrace, 13 | }) = _Error; 14 | } 15 | -------------------------------------------------------------------------------- /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 | com.apple.security.network.client 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 14 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Request an estimate App with riverpod and freezed 2 | 3 | Simple Flutter App to showcase MVC+S pattern using riverpod and freezed package. 4 | 5 | #### Backend : [Superbase](https://supabase.com/) REST API ([PostgREST](https://postgrest.org/)) 6 | 7 | #### Screenshots 8 | 9 | | Home | Submit | 10 | |--------------|-----------| 11 | | | | 12 | 13 | TODO: 14 | 15 | * [x] Use freezed package 16 | * [x] User authentication 17 | * [ ] Details page 18 | * [ ] Edit item 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/features/estimates/models/quote_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:freezed_annotation/freezed_annotation.dart'; 2 | 3 | part 'quote_model.freezed.dart'; 4 | part 'quote_model.g.dart'; 5 | 6 | @freezed 7 | class Quote with _$Quote { 8 | const factory Quote({ 9 | int? id, 10 | @JsonKey(name: 'product_name') 11 | required String productName, 12 | required String description, 13 | @JsonKey(name: 'product_link') 14 | required String productLink, 15 | required int quantity, 16 | @JsonKey(name: 'created_at') 17 | DateTime? createdAt, 18 | }) = _Quote; 19 | 20 | factory Quote.fromJson(Map json) => _$QuoteFromJson(json); 21 | } 22 | -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = flutter_riverpod_app 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterRiverpodApp 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/core/widgets/delete_item_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class DeteleItemDialog extends StatelessWidget { 4 | const DeteleItemDialog({Key? key}) : super(key: key); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return AlertDialog( 9 | title: const Text("Detele item"), 10 | content: const Text("Are you sure you wish to delete this item?"), 11 | actions: [ 12 | TextButton( 13 | onPressed: () => Navigator.of(context).pop(true), 14 | child: const Text("DELETE"), 15 | ), 16 | TextButton( 17 | onPressed: () => Navigator.of(context).pop(false), 18 | child: const Text("CANCEL"), 19 | ), 20 | ], 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/src/features/auth/models/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) => _$_UserModel( 10 | uuid: json['uuid'] as String?, 11 | password: json['password'] as String?, 12 | email: json['email'] as String, 13 | ); 14 | 15 | Map _$$_UserModelToJson(_$_UserModel instance) => 16 | { 17 | 'uuid': instance.uuid, 18 | 'password': instance.password, 19 | 'email': instance.email, 20 | }; 21 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_linux 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - path_provider_ios (0.0.1): 4 | - Flutter 5 | - url_launcher_ios (0.0.1): 6 | - Flutter 7 | 8 | DEPENDENCIES: 9 | - Flutter (from `Flutter`) 10 | - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) 11 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) 12 | 13 | EXTERNAL SOURCES: 14 | Flutter: 15 | :path: Flutter 16 | path_provider_ios: 17 | :path: ".symlinks/plugins/path_provider_ios/ios" 18 | url_launcher_ios: 19 | :path: ".symlinks/plugins/url_launcher_ios/ios" 20 | 21 | SPEC CHECKSUMS: 22 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 23 | path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02 24 | url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de 25 | 26 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 27 | 28 | COCOAPODS: 1.11.3 29 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_windows 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: quote_request_app 2 | description: Simple riverpod demo app. 3 | 4 | publish_to: 'none' 5 | 6 | version: 1.0.0+1 7 | 8 | environment: 9 | sdk: ">=2.17.5 <3.0.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | google_fonts: ^3.0.1 16 | 17 | cupertino_icons: ^1.0.2 18 | flutter_riverpod: ^1.0.4 19 | riverpod: ^1.0.3 20 | equatable: ^2.0.5 21 | dio: any 22 | url_launcher: ^6.1.5 23 | intl: ^0.17.0 24 | freezed_annotation: ^2.1.0 25 | json_annotation: ^4.6.0 26 | go_router: ^6.0.1 27 | 28 | dev_dependencies: 29 | flutter_test: 30 | sdk: flutter 31 | flutter_launcher_icons: ^0.9.3 32 | 33 | flutter_lints: ^2.0.0 34 | build_runner: ^2.2.0 35 | freezed: ^2.1.0+1 36 | json_serializable: ^6.3.1 37 | 38 | flutter: 39 | 40 | uses-material-design: true 41 | 42 | flutter_icons: 43 | android: "launcher_icon" 44 | ios: false 45 | image_path: "assets/logo.png" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Web related 36 | lib/generated_plugin_registrant.dart 37 | 38 | # Symbolication related 39 | app.*.symbols 40 | 41 | # Obfuscation related 42 | app.*.map.json 43 | 44 | # Android Studio will place build artifacts here 45 | /android/app/debug 46 | /android/app/profile 47 | /android/app/release 48 | -------------------------------------------------------------------------------- /lib/src/features/auth/models/user_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:freezed_annotation/freezed_annotation.dart'; 2 | 3 | part 'user_model.freezed.dart'; 4 | part 'user_model.g.dart'; 5 | 6 | @freezed 7 | class UserModel with _$UserModel { 8 | @JsonSerializable(explicitToJson: true) 9 | const factory UserModel({ 10 | String? uuid, 11 | String? password, 12 | // @JsonKey(name: 'address', fromJson: addressFromJson) String? address, 13 | required String email, 14 | // @JsonKey(name: 'fullname', fromJson: fullnameFromJson) required String fullname, 15 | }) = _UserModel; 16 | 17 | factory UserModel.fromJson(Map json) => 18 | _$UserModelFromJson(json); 19 | 20 | static String fullnameFromJson(Map json) { 21 | return json['user_metadata']['fullname'] as String; 22 | } 23 | 24 | static String addressFromJson(Map json) { 25 | return json['user_metadata']['address'] as String; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:google_fonts/google_fonts.dart'; 4 | 5 | import 'core/app_router.dart'; 6 | 7 | class QuoteRequestApp extends ConsumerWidget { 8 | const QuoteRequestApp({Key? key}) : super(key: key); 9 | 10 | @override 11 | Widget build(BuildContext context, WidgetRef ref) { 12 | final router = ref.watch(goRouterProvider); 13 | return ProviderScope( 14 | child: MaterialApp.router( 15 | debugShowCheckedModeBanner: false, 16 | title: 'MVC Riverpod Freezed App', 17 | theme: ThemeData( 18 | primarySwatch: Colors.indigo, 19 | textTheme: GoogleFonts.poppinsTextTheme(), 20 | ), 21 | routeInformationParser: router.routeInformationParser, 22 | routeInformationProvider: router.routeInformationProvider, 23 | routerDelegate: router.routerDelegate, 24 | ), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FlutterMacOS (1.0.0) 3 | - path_provider_macos (0.0.1): 4 | - FlutterMacOS 5 | - url_launcher_macos (0.0.1): 6 | - FlutterMacOS 7 | 8 | DEPENDENCIES: 9 | - FlutterMacOS (from `Flutter/ephemeral`) 10 | - path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`) 11 | - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) 12 | 13 | EXTERNAL SOURCES: 14 | FlutterMacOS: 15 | :path: Flutter/ephemeral 16 | path_provider_macos: 17 | :path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos 18 | url_launcher_macos: 19 | :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos 20 | 21 | SPEC CHECKSUMS: 22 | FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811 23 | path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19 24 | url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3 25 | 26 | PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c 27 | 28 | COCOAPODS: 1.11.3 29 | -------------------------------------------------------------------------------- /lib/src/core/styles.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class AppInputBorder { 4 | static const enabledBorder = OutlineInputBorder( 5 | borderSide: BorderSide(color: Color(0xFFC2C9D1), width: 1.5), 6 | borderRadius: BorderRadius.all(Radius.circular(10)), 7 | ); 8 | 9 | static const focusedBorder = OutlineInputBorder( 10 | borderSide: BorderSide(color: Colors.black45, width: 1.5), 11 | borderRadius: BorderRadius.all(Radius.circular(10)), 12 | ); 13 | 14 | static const errorBorder = OutlineInputBorder( 15 | borderSide: BorderSide(color: Color(0xFFE02424), width: 1.5), 16 | borderRadius: BorderRadius.all(Radius.circular(10)), 17 | ); 18 | 19 | static const disabledBorder = OutlineInputBorder( 20 | borderSide: BorderSide(color: Color(0xFFE02424), width: 1.5), 21 | borderRadius: BorderRadius.all(Radius.circular(10)), 22 | ); 23 | 24 | static const focusedErrorBorder = OutlineInputBorder( 25 | borderSide: BorderSide(color: Color(0xFFE02424), width: 1.5), 26 | borderRadius: BorderRadius.all(Radius.circular(10)), 27 | ); 28 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /lib/src/core/widgets/no_data_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class NoDataWidget extends StatelessWidget { 4 | const NoDataWidget({Key? key}) : super(key: key); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return Container( 9 | width: double.infinity, 10 | height: 100, 11 | margin: const EdgeInsets.symmetric(horizontal: 16), 12 | decoration: BoxDecoration( 13 | color: Colors.white, 14 | borderRadius: BorderRadius.circular(10), 15 | border: Border.all(color: Colors.grey.shade400), 16 | ), 17 | child: Column( 18 | mainAxisAlignment: MainAxisAlignment.center, 19 | children: [ 20 | Icon( 21 | Icons.info, 22 | color: Colors.grey.shade400, 23 | size: 32, 24 | ), 25 | const SizedBox(height: 16), 26 | const Text( 27 | 'No request submitted yet. Please, add a quote.', 28 | style: TextStyle(fontSize: 16), 29 | ), 30 | ], 31 | ), 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_riverpod_app", 3 | "short_name": "flutter_riverpod_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 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /lib/src/features/auth/controllers/auth_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:riverpod/riverpod.dart'; 2 | 3 | import '../../../core/data_state.dart'; 4 | import '../services/auth_service.dart'; 5 | 6 | class AuthController extends StateNotifier { 7 | AuthController(this._authService) : super(const DataState.initial()); 8 | 9 | final AuthService _authService; 10 | 11 | Future login(Map credentials) async { 12 | state = const DataState.loading(); 13 | try { 14 | final user = await _authService.login( 15 | credentials['email'], 16 | credentials['password'], 17 | ); 18 | state = DataState.success(data: user); 19 | } catch (e) { 20 | state = DataState.error(message: e.toString()); 21 | } 22 | } 23 | 24 | Future register(Map userData) async { 25 | state = const DataState.loading(); 26 | try { 27 | final user = await _authService.register(userData); 28 | state = DataState.success(data: user); 29 | } catch (e) { 30 | state = DataState.error(message: e.toString()); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/src/features/estimates/models/quote_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'quote_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _$_Quote _$$_QuoteFromJson(Map json) => _$_Quote( 10 | id: json['id'] as int?, 11 | productName: json['product_name'] as String, 12 | description: json['description'] as String, 13 | productLink: json['product_link'] as String, 14 | quantity: json['quantity'] as int, 15 | createdAt: json['created_at'] == null 16 | ? null 17 | : DateTime.parse(json['created_at'] as String), 18 | ); 19 | 20 | Map _$$_QuoteToJson(_$_Quote instance) => { 21 | 'id': instance.id, 22 | 'product_name': instance.productName, 23 | 'description': instance.description, 24 | 'product_link': instance.productLink, 25 | 'quantity': instance.quantity, 26 | 'created_at': instance.createdAt?.toIso8601String(), 27 | }; 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"flutter_riverpod_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 | -------------------------------------------------------------------------------- /lib/src/features/estimates/services/estimate_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | 3 | import '../models/quote_model.dart'; 4 | 5 | class EstimateService { 6 | final Dio _dio; 7 | 8 | EstimateService(this._dio); 9 | 10 | Future> getEstimates() async { 11 | try { 12 | final response = await _dio.get('/rest/v1/requests', queryParameters: { 13 | 'order': 'created_at.desc', 14 | }); 15 | 16 | return (response.data as List) 17 | .map((e) => Quote.fromJson(e)) 18 | .toList(); 19 | } catch (_) { 20 | throw Exception("Couldn't fetch quotes. Is the device online?"); 21 | } 22 | } 23 | 24 | Future submitEstimate(Map quote) async { 25 | try { 26 | final response = await _dio.post('/rest/v1/requests', data: quote); 27 | 28 | if (response.statusCode == 201) { 29 | return Quote.fromJson(response.data.first); 30 | } else { 31 | throw Exception('Error submitting request quote'); 32 | } 33 | } catch (_) { 34 | throw Exception("Couldn't submit quote. Is the device online?"); 35 | } 36 | } 37 | 38 | Future deleteEstimate(int estimateId) async { 39 | try { 40 | await _dio.delete( 41 | '/rest/v1/requests', 42 | queryParameters: {'id': 'eq.$estimateId'}, 43 | ); 44 | } catch (_) { 45 | throw Exception("Couldn't delete estimate. Is the device online?"); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/src/features/auth/services/auth_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | 4 | import '../models/user_model.dart'; 5 | 6 | class AuthService { 7 | final Dio _dio; 8 | 9 | AuthService(this._dio); 10 | 11 | Future login(String email, String password) async { 12 | try { 13 | final response = await _dio.post( 14 | '/auth/v1/token', 15 | queryParameters: {'grant_type': 'password'}, 16 | data: {'email': email, 'password': password}, 17 | ); 18 | 19 | if (response.statusCode == 200) { 20 | return UserModel.fromJson(response.data['user']); 21 | } else { 22 | throw Exception('An error occurred'); 23 | } 24 | } on DioError catch (e) { 25 | throw Exception(e.response!.data['error_description']); 26 | } catch (e) { 27 | throw Exception("Couldn't login. Is the device online?"); 28 | } 29 | } 30 | 31 | Future register(Map userData) async { 32 | try { 33 | final response = await _dio.post('/auth/v1/signup', data: userData); 34 | return UserModel.fromJson(response.data); 35 | } on DioError catch (e) { 36 | if (e.response!.statusCode == 400) { 37 | throw Exception(e.response!.data['error_description']); 38 | } else { 39 | throw Exception(e.message); 40 | } 41 | } catch (e, stack) { 42 | debugPrint('Error: $e\nStack : $stack'); 43 | throw Exception("Couldn't register. Is the device online?"); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/src/features/estimates/controllers/estimate_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 2 | 3 | import '../../../core/data_state.dart'; 4 | import '../models/quote_model.dart'; 5 | import '../services/estimate_service.dart'; 6 | 7 | class EstimateController extends StateNotifier { 8 | EstimateController(this._estimateService) : super(const DataState.initial()); 9 | 10 | final EstimateService _estimateService; 11 | 12 | List _quotes = []; 13 | 14 | Future getQuotes() async { 15 | state = const DataState.loading(); 16 | try { 17 | _quotes = await _estimateService.getEstimates(); 18 | state = DataState.success(data: _quotes); 19 | } on Exception catch (err) { 20 | state = DataState.error(message: err.toString()); 21 | } 22 | } 23 | 24 | Future submitQuote(Map data) async { 25 | state = const DataState.loading(); 26 | try { 27 | final quote = await _estimateService.submitEstimate(data); 28 | _quotes.add(quote); 29 | state = DataState.success(data: _quotes); 30 | } on Exception catch (err) { 31 | state = DataState.error(message: err.toString()); 32 | } 33 | } 34 | 35 | Future delete(int id) async { 36 | try { 37 | await _estimateService.deleteEstimate(id); 38 | 39 | _quotes.removeWhere((quote) => quote.id == id); 40 | 41 | state = DataState.success(data: _quotes); 42 | } catch (e) { 43 | state = DataState.error(message: e.toString()); 44 | throw Exception(e.toString()); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | analyzer: 12 | errors: 13 | invalid_annotation_target: ignore 14 | 15 | linter: 16 | # The lint rules applied to this project can be customized in the 17 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 18 | # included above or to enable additional rules. A list of all available lints 19 | # and their documentation is published at 20 | # https://dart-lang.github.io/linter/lints/index.html. 21 | # 22 | # Instead of disabling a lint rule for the entire project in the 23 | # section below, it can also be suppressed for a single line of code 24 | # or a specific dart file by using the `// ignore: name_of_lint` and 25 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 26 | # producing the lint. 27 | rules: 28 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 29 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 30 | 31 | # Additional information about this file can be found at 32 | # https://dart.dev/guides/language/analysis-options 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/features/estimates/views/estimate_form_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:quote_request_app/src/core/widgets/estimate_form.dart'; 4 | 5 | import '../../../core/data_state.dart'; 6 | import '../../../core/providers.dart'; 7 | import '../models/quote_model.dart'; 8 | 9 | class EstimateFormView extends ConsumerStatefulWidget { 10 | const EstimateFormView({Key? key}) : super(key: key); 11 | 12 | @override 13 | EstimateFormViewState createState() => EstimateFormViewState(); 14 | } 15 | 16 | class EstimateFormViewState extends ConsumerState { 17 | void _onSubmitted(Quote quote) { 18 | ref.read(estimateNotifierProvider.notifier).submitQuote(quote.toJson()); 19 | } 20 | 21 | @override 22 | Widget build(BuildContext context) { 23 | ref.listen(estimateNotifierProvider, (_, state) { 24 | state.maybeWhen( 25 | success: (_) => Navigator.of(context).pop(), 26 | error: (error, _) { 27 | ScaffoldMessenger.of(context).showSnackBar( 28 | SnackBar(content: Text('Error: $error')), 29 | ); 30 | }, 31 | orElse: () {}, 32 | ); 33 | }); 34 | 35 | return Scaffold( 36 | backgroundColor: const Color(0xFFFAFAFA), 37 | appBar: AppBar( 38 | elevation: 2.0, 39 | title: const Text( 40 | 'Request an estimate', 41 | style: TextStyle( 42 | color: Colors.white, 43 | fontWeight: FontWeight.bold, 44 | fontSize: 24, 45 | ), 46 | ), 47 | centerTitle: true, 48 | ), 49 | body: EstimateForm(onSubmitted: _onSubmitted), 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 135454af32477f815a7525073027a3ff9eff1bfd 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 17 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 18 | - platform: android 19 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 20 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 21 | - platform: ios 22 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 23 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 24 | - platform: linux 25 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 26 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 27 | - platform: macos 28 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 29 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 30 | - platform: web 31 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 32 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 33 | - platform: windows 34 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 35 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 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 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 37 | 38 | # Run the Flutter tool portions of the build. This must not be removed. 39 | add_dependencies(${BINARY_NAME} flutter_assemble) 40 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 16 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /lib/src/core/providers.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 4 | import 'package:intl/date_symbol_data_local.dart'; 5 | import 'package:intl/intl.dart'; 6 | 7 | import '../features/auth/controllers/auth_controller.dart'; 8 | import '../features/auth/services/auth_service.dart'; 9 | import '../features/estimates/controllers/estimate_controller.dart'; 10 | import '../features/estimates/services/estimate_service.dart'; 11 | import 'constants.dart'; 12 | import 'data_state.dart'; 13 | import 'widgets/delete_item_dialog.dart'; 14 | 15 | final dioProvider = Provider( 16 | (ref) => Dio( 17 | BaseOptions( 18 | headers: { 19 | 'apikey': kApiKey, 20 | 'Prefer': 'return=representation', 21 | }, 22 | baseUrl: kBaseUrl, 23 | ), 24 | ), 25 | ); 26 | 27 | final dateFormatProvider = Provider((_) { 28 | initializeDateFormatting(); 29 | 30 | return DateFormat('yyyy-MM-dd hh:mm'); 31 | }); 32 | 33 | final confirmDialogProvider = 34 | Provider.family((ref, BuildContext context) async { 35 | return await showDialog>( 36 | context: context, 37 | builder: (BuildContext context) { 38 | return const DeteleItemDialog(); 39 | }, 40 | ); 41 | }); 42 | 43 | //Services 44 | final estimateServiceProvider = Provider( 45 | (ref) => EstimateService(ref.read(dioProvider)), 46 | ); 47 | 48 | final authServiceProvider = Provider( 49 | (ref) => AuthService(ref.read(dioProvider)), 50 | ); 51 | 52 | //Notifiers 53 | final estimateNotifierProvider = 54 | StateNotifierProvider( 55 | (ref) => EstimateController(ref.read(estimateServiceProvider)), 56 | ); 57 | 58 | final authNotifier = StateNotifierProvider( 59 | (ref) => AuthController(ref.read(authServiceProvider)), 60 | ); 61 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Flutter Riverpod App 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_riverpod_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 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | flutter_riverpod_app 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /lib/src/core/form_validator.dart: -------------------------------------------------------------------------------- 1 | class FormValidator { 2 | static String? validateProductLink(String? value) { 3 | String urlPatttern = r'((http|https)://)(www.)?[a-zA-Z0-9@:%._\\+~#?&//=]' 4 | '{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%._\\+~#?&//=]*)'; 5 | RegExp regExp = RegExp(urlPatttern); 6 | 7 | if (value!.isEmpty) { 8 | return 'Please enter the product link'; 9 | } else if (!regExp.hasMatch(value)) { 10 | return 'Please enter a valid product link'; 11 | } 12 | 13 | return null; 14 | } 15 | 16 | static String? validateProductName(String? value) { 17 | return value!.isEmpty ? 'Please enter the product name' : null; 18 | } 19 | 20 | static String? validateProductDescription(String? value) { 21 | return value!.isEmpty ? 'Please enter the product description' : null; 22 | } 23 | 24 | static String? validateProductQuantity(String? value) { 25 | return value!.isEmpty ? 'Please enter product quantity' : null; 26 | } 27 | 28 | //Authentication 29 | static String? validateEmail(String? value) { 30 | String emailPattern = 31 | r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'; 32 | RegExp regExp = RegExp(emailPattern); 33 | 34 | if (value!.isEmpty) { 35 | return 'Please enter your email address'; 36 | } else if (!regExp.hasMatch(value)) { 37 | return 'Please enter a valid email'; 38 | } 39 | return null; 40 | } 41 | 42 | static String? validatePassword(String? value) { 43 | return value!.isEmpty ? 'Please enter your password' : null; 44 | } 45 | 46 | static String? validateFullName(String? value) { 47 | return value!.isEmpty ? 'Please enter your fullname' : null; 48 | } 49 | 50 | //validatePasswordConfirmation 51 | static String? validatePasswordConfirmation(String? value, String password) { 52 | if (value!.isEmpty) { 53 | return 'Please enter your password confirmation'; 54 | } else if (value != password) { 55 | return 'Password confirmation does not match'; 56 | } 57 | return null; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.example.quote_request_app" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 50 | minSdkVersion 19 51 | targetSdkVersion 30 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/core/app_router.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 4 | import 'package:go_router/go_router.dart'; 5 | 6 | import '../features/auth/views/login_view.dart'; 7 | import '../features/auth/views/register_view.dart'; 8 | import '../features/estimates/views/estimate_form_view.dart'; 9 | import '../features/estimates/views/estimates_vew.dart'; 10 | 11 | enum AppRoutes { 12 | login('/login'), 13 | register('/register'), 14 | home('/home'), 15 | submitRequest('/submit'); 16 | 17 | const AppRoutes(this.path); 18 | 19 | final String path; 20 | } 21 | 22 | Page errorPage(BuildContext context, GoRouterState state) { 23 | return CupertinoPage( 24 | child: const Scaffold(), 25 | key: state.pageKey, 26 | ); 27 | } 28 | 29 | class AppRouter { 30 | AppRouter(this.ref); 31 | 32 | final Ref ref; 33 | 34 | GoRouter get router { 35 | return GoRouter( 36 | initialLocation: AppRoutes.home.path, 37 | errorPageBuilder: errorPage, 38 | debugLogDiagnostics: true, 39 | routes: [ 40 | GoRoute( 41 | path: AppRoutes.login.path, 42 | name: AppRoutes.login.name, 43 | pageBuilder: (context, state) => CupertinoPage( 44 | child: const LoginView(), 45 | key: state.pageKey, 46 | restorationId: state.pageKey.value, 47 | ), 48 | ), 49 | GoRoute( 50 | path: AppRoutes.register.path, 51 | name: AppRoutes.register.name, 52 | pageBuilder: (context, state) => CupertinoPage( 53 | child: const RegisterView(), 54 | key: state.pageKey, 55 | restorationId: state.pageKey.value, 56 | ), 57 | ), 58 | GoRoute( 59 | path: AppRoutes.home.path, 60 | name: AppRoutes.home.name, 61 | pageBuilder: (context, state) => CupertinoPage( 62 | child: const EstimatesView(), 63 | key: state.pageKey, 64 | restorationId: state.pageKey.value, 65 | ), 66 | ), 67 | GoRoute( 68 | path: AppRoutes.submitRequest.path, 69 | name: AppRoutes.submitRequest.name, 70 | pageBuilder: (context, state) => CupertinoPage( 71 | child: const EstimateFormView(), 72 | key: state.pageKey, 73 | restorationId: state.pageKey.value, 74 | ), 75 | ), 76 | ] 77 | ); 78 | } 79 | } 80 | 81 | final goRouterProvider = Provider((ref) { 82 | return AppRouter(ref).router; 83 | }); 84 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "flutter_riverpod_app" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "flutter_riverpod_app" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "flutter_riverpod_app.exe" "\0" 98 | VALUE "ProductName", "flutter_riverpod_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/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /lib/src/features/estimates/views/estimates_vew.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | 5 | import '../../../core/app_router.dart'; 6 | import '../../../core/providers.dart'; 7 | import '../../../core/widgets/no_data_widget.dart'; 8 | import '../../../core/widgets/request_quote_row.dart'; 9 | 10 | class EstimatesView extends ConsumerStatefulWidget { 11 | const EstimatesView({Key? key}) : super(key: key); 12 | 13 | @override 14 | EstimatesViewState createState() => EstimatesViewState(); 15 | } 16 | 17 | class EstimatesViewState extends ConsumerState { 18 | @override 19 | void initState() { 20 | super.initState(); 21 | ref.read(estimateNotifierProvider.notifier).getQuotes(); 22 | } 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | return Scaffold( 27 | backgroundColor: const Color(0xFFFAFAFA), 28 | appBar: AppBar( 29 | elevation: 2.0, 30 | title: const Text( 31 | 'Estimates list', 32 | style: TextStyle( 33 | color: Colors.white, 34 | fontWeight: FontWeight.bold, 35 | fontSize: 24, 36 | ), 37 | ), 38 | centerTitle: true, 39 | ), 40 | body: Consumer( 41 | builder: (context, ref, child) { 42 | final quotesListState = ref.watch(estimateNotifierProvider); 43 | 44 | return quotesListState.maybeWhen( 45 | loading: () => const Center( 46 | child: CircularProgressIndicator(), 47 | ), 48 | success: (quotes) { 49 | if (quotes.isEmpty) return const NoDataWidget(); 50 | 51 | return ListView.builder( 52 | padding: const EdgeInsets.all(16), 53 | itemCount: quotes.length, 54 | itemBuilder: (context, index) { 55 | final quote = quotes[index]; 56 | return Dismissible( 57 | key: UniqueKey(), 58 | confirmDismiss: (_) => ref.watch( 59 | confirmDialogProvider(context), 60 | ), 61 | onDismissed: (direction) { 62 | ref 63 | .read(estimateNotifierProvider.notifier) 64 | .delete(quote.id!); 65 | 66 | ScaffoldMessenger.of(context).showSnackBar( 67 | const SnackBar( 68 | content: Text('Quote deleted successfully!'), 69 | ), 70 | ); 71 | }, 72 | child: RequestQuoteRow(quote: quote), 73 | ); 74 | }, 75 | ); 76 | }, 77 | error: (err, _) => Center(child: Text(err)), 78 | orElse: () => const Center( 79 | child: CircularProgressIndicator(), 80 | ), 81 | ); 82 | }, 83 | ), 84 | floatingActionButton: FloatingActionButton.extended( 85 | onPressed: () => context.pushNamed(AppRoutes.submitRequest.name), 86 | label: Row( 87 | children: const [ 88 | Icon(Icons.pending_actions), 89 | SizedBox(width: 8), 90 | Text( 91 | 'Request estimate', 92 | style: TextStyle(fontWeight: FontWeight.bold), 93 | ), 94 | ], 95 | ), 96 | shape: const RoundedRectangleBorder( 97 | borderRadius: BorderRadius.all(Radius.circular(16)), 98 | ), 99 | ), 100 | ); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /lib/src/core/widgets/request_quote_row.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:url_launcher/url_launcher.dart'; 4 | 5 | import '../providers.dart'; 6 | import '../../features/estimates/models/quote_model.dart'; 7 | 8 | class RequestQuoteRow extends ConsumerWidget { 9 | final Quote quote; 10 | 11 | const RequestQuoteRow({Key? key, required this.quote}) : super(key: key); 12 | 13 | Future _launchUrl(String url) async { 14 | if (!await launchUrl(Uri.parse(url))) { 15 | throw 'Could not launch $url'; 16 | } 17 | } 18 | 19 | @override 20 | Widget build(BuildContext context, WidgetRef ref) { 21 | final dateFormat = ref.watch(dateFormatProvider); 22 | return Container( 23 | height: 88, 24 | margin: const EdgeInsets.only(bottom: 10), 25 | decoration: BoxDecoration( 26 | color: Colors.white, 27 | borderRadius: const BorderRadius.all(Radius.circular(10)), 28 | border: Border.all(color: const Color(0xFFC2C9D1)), 29 | ), 30 | child: InkWell( 31 | onTap: () {}, 32 | child: Padding( 33 | padding: const EdgeInsets.all(8.0), 34 | child: Row( 35 | children: [ 36 | Expanded( 37 | child: InkWell( 38 | onTap: () => _launchUrl(quote.productLink), 39 | child: Container( 40 | height: double.infinity, 41 | decoration: BoxDecoration( 42 | color: Colors.grey.shade200, 43 | borderRadius: const BorderRadius.all( 44 | Radius.circular(10), 45 | ), 46 | ), 47 | child: const Icon( 48 | Icons.launch, 49 | color: Colors.black45, 50 | size: 20, 51 | ), 52 | ), 53 | ), 54 | ), 55 | const SizedBox(width: 8), 56 | Expanded( 57 | flex: 4, 58 | child: Column( 59 | crossAxisAlignment: CrossAxisAlignment.start, 60 | children: [ 61 | Text( 62 | quote.productName, 63 | style: const TextStyle( 64 | color: Colors.black, 65 | fontSize: 16, 66 | fontWeight: FontWeight.bold, 67 | overflow: TextOverflow.ellipsis, 68 | ), 69 | ), 70 | Row( 71 | crossAxisAlignment: CrossAxisAlignment.start, 72 | children: [ 73 | Expanded( 74 | child: Text( 75 | quote.description, 76 | style: const TextStyle( 77 | color: Colors.black45, 78 | fontSize: 12, 79 | overflow: TextOverflow.ellipsis, 80 | ), 81 | ), 82 | ), 83 | const SizedBox(width: 8), 84 | Text('x ${quote.quantity}') 85 | ], 86 | ), 87 | const Spacer(), 88 | Row( 89 | mainAxisAlignment: MainAxisAlignment.end, 90 | children: [ 91 | Text( 92 | dateFormat.format(quote.createdAt!), 93 | style: const TextStyle( 94 | color: Colors.black45, 95 | fontSize: 12, 96 | ), 97 | ), 98 | ], 99 | ) 100 | ], 101 | ), 102 | ), 103 | ], 104 | ), 105 | ), 106 | ), 107 | ); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "quote_request_app"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "quote_request_app"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(flutter_riverpod_app LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "flutter_riverpod_app") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.10) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "quote_request_app") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.quote_request_app") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 | 59 | # Define the application target. To change its name, change BINARY_NAME above, 60 | # not the value here, or `flutter run` will no longer work. 61 | # 62 | # Any new source files that you add to the application should be added here. 63 | add_executable(${BINARY_NAME} 64 | "main.cc" 65 | "my_application.cc" 66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 | ) 68 | 69 | # Apply the standard set of build settings. This can be removed for applications 70 | # that need different build settings. 71 | apply_standard_settings(${BINARY_NAME}) 72 | 73 | # Add dependency libraries. Add any application-specific dependencies here. 74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 | 77 | # Run the Flutter tool portions of the build. This must not be removed. 78 | add_dependencies(${BINARY_NAME} flutter_assemble) 79 | 80 | # Only the install-generated bundle's copy of the executable will launch 81 | # correctly, since the resources must in the right relative locations. To avoid 82 | # people trying to run the unbundled copy, put it in a subdirectory instead of 83 | # the default top-level location. 84 | set_target_properties(${BINARY_NAME} 85 | PROPERTIES 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 | ) 88 | 89 | # Generated plugin build rules, which manage building the plugins and adding 90 | # them to the application. 91 | include(flutter/generated_plugins.cmake) 92 | 93 | 94 | # === Installation === 95 | # By default, "installing" just makes a relocatable bundle in the build 96 | # directory. 97 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 98 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 99 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 100 | endif() 101 | 102 | # Start with a clean build bundle directory every time. 103 | install(CODE " 104 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 105 | " COMPONENT Runtime) 106 | 107 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 108 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 109 | 110 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 111 | COMPONENT Runtime) 112 | 113 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 114 | COMPONENT Runtime) 115 | 116 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 117 | COMPONENT Runtime) 118 | 119 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 120 | install(FILES "${bundled_library}" 121 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 122 | COMPONENT Runtime) 123 | endforeach(bundled_library) 124 | 125 | # Fully re-copy the assets directory on each build to avoid having stale files 126 | # from a previous install. 127 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 128 | install(CODE " 129 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 130 | " COMPONENT Runtime) 131 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 132 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 133 | 134 | # Install the AOT library on non-Debug builds only. 135 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 136 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 137 | COMPONENT Runtime) 138 | endif() 139 | -------------------------------------------------------------------------------- /lib/src/core/widgets/estimate_form.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:quote_request_app/src/features/estimates/models/quote_model.dart'; 4 | 5 | import '../form_validator.dart'; 6 | import '../providers.dart'; 7 | import '../styles.dart'; 8 | import 'loading_widget.dart'; 9 | 10 | class EstimateForm extends ConsumerStatefulWidget { 11 | const EstimateForm({this.initalQuote, required this.onSubmitted, super.key}); 12 | 13 | final Quote? initalQuote; 14 | final void Function(Quote quote) onSubmitted; 15 | 16 | @override 17 | ConsumerState createState() => _EstimateFormState(); 18 | } 19 | 20 | class _EstimateFormState extends ConsumerState { 21 | final _formKey = GlobalKey(); 22 | 23 | final TextEditingController _productLinkController = TextEditingController(); 24 | final TextEditingController _productNameController = TextEditingController(); 25 | final TextEditingController _descriptionController = TextEditingController(); 26 | final TextEditingController _quantityController = TextEditingController(); 27 | 28 | void _handleFormSubmission() { 29 | if (_formKey.currentState!.validate()) { 30 | _formKey.currentState!.save(); 31 | 32 | Map data = { 33 | 'product_name': _productNameController.text, 34 | 'product_link': _productLinkController.text, 35 | 'description': _descriptionController.text, 36 | 'quantity': _quantityController.text, 37 | }; 38 | 39 | widget.onSubmitted(Quote.fromJson(data)); 40 | } 41 | } 42 | 43 | @override 44 | Widget build(BuildContext context) { 45 | final quoteState = ref.watch(estimateNotifierProvider); 46 | return Form( 47 | key: _formKey, 48 | child: ListView( 49 | padding: const EdgeInsets.all(16), 50 | children: [ 51 | const Text( 52 | "Link to the product", 53 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 54 | ), 55 | const SizedBox(height: 8), 56 | TextFormField( 57 | controller: _productLinkController, 58 | keyboardType: TextInputType.url, 59 | decoration: const InputDecoration( 60 | hintText: 'https://www.amazon.fr/dp/289225955X', 61 | labelStyle: TextStyle(color: Colors.grey), 62 | enabledBorder: AppInputBorder.enabledBorder, 63 | focusedBorder: AppInputBorder.focusedBorder, 64 | errorBorder: AppInputBorder.errorBorder, 65 | focusedErrorBorder: AppInputBorder.focusedErrorBorder, 66 | contentPadding: EdgeInsets.all(10), 67 | ), 68 | validator: FormValidator.validateProductLink, 69 | ), 70 | const SizedBox(height: 16), 71 | const Text( 72 | "Product name", 73 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 74 | ), 75 | const SizedBox(height: 8), 76 | TextFormField( 77 | controller: _productNameController, 78 | decoration: const InputDecoration( 79 | hintText: 'Enter product name', 80 | labelStyle: TextStyle(color: Colors.grey), 81 | enabledBorder: AppInputBorder.enabledBorder, 82 | focusedBorder: AppInputBorder.focusedBorder, 83 | errorBorder: AppInputBorder.errorBorder, 84 | contentPadding: EdgeInsets.all(10), 85 | ), 86 | validator: FormValidator.validateProductName, 87 | ), 88 | const SizedBox(height: 16), 89 | const Text( 90 | "Description", 91 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 92 | ), 93 | const SizedBox(height: 8), 94 | TextFormField( 95 | controller: _descriptionController, 96 | decoration: const InputDecoration( 97 | hintText: 'Product details', 98 | labelStyle: TextStyle(color: Colors.grey), 99 | enabledBorder: AppInputBorder.enabledBorder, 100 | focusedBorder: AppInputBorder.focusedBorder, 101 | errorBorder: AppInputBorder.errorBorder, 102 | contentPadding: EdgeInsets.all(10), 103 | ), 104 | maxLines: 6, 105 | validator: FormValidator.validateProductDescription, 106 | ), 107 | const SizedBox(height: 16), 108 | const Text( 109 | "Quantity", 110 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 111 | ), 112 | const SizedBox(height: 8), 113 | TextFormField( 114 | controller: _quantityController, 115 | keyboardType: TextInputType.number, 116 | decoration: const InputDecoration( 117 | hintText: 'Product quantity', 118 | labelStyle: TextStyle(color: Colors.grey), 119 | enabledBorder: AppInputBorder.enabledBorder, 120 | focusedBorder: AppInputBorder.focusedBorder, 121 | errorBorder: AppInputBorder.errorBorder, 122 | contentPadding: EdgeInsets.all(10), 123 | ), 124 | validator: FormValidator.validateProductQuantity, 125 | ), 126 | const SizedBox(height: 24), 127 | ElevatedButton( 128 | onPressed: quoteState.maybeWhen( 129 | loading: () => null, 130 | orElse: () => _handleFormSubmission, 131 | ), 132 | style: ElevatedButton.styleFrom( 133 | elevation: 0, 134 | shape: RoundedRectangleBorder( 135 | borderRadius: BorderRadius.circular(10), 136 | ), 137 | padding: const EdgeInsets.symmetric(vertical: 16), 138 | ), 139 | child: quoteState.maybeWhen( 140 | loading: () => const LoadingWidget(), 141 | orElse: () => const Text('SUBMIT REQUEST'), 142 | ), 143 | ), 144 | ], 145 | ), 146 | ); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /lib/src/features/auth/models/user_model.freezed.dart: -------------------------------------------------------------------------------- 1 | // coverage:ignore-file 2 | // GENERATED CODE - DO NOT MODIFY BY HAND 3 | // ignore_for_file: type=lint 4 | // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target 5 | 6 | part of 'user_model.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | T _$identity(T value) => value; 13 | 14 | final _privateConstructorUsedError = UnsupportedError( 15 | 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); 16 | 17 | UserModel _$UserModelFromJson(Map json) { 18 | return _UserModel.fromJson(json); 19 | } 20 | 21 | /// @nodoc 22 | mixin _$UserModel { 23 | String? get uuid => throw _privateConstructorUsedError; 24 | String? get password => 25 | throw _privateConstructorUsedError; // @JsonKey(name: 'address', fromJson: addressFromJson) String? address, 26 | String get email => throw _privateConstructorUsedError; 27 | 28 | Map toJson() => throw _privateConstructorUsedError; 29 | @JsonKey(ignore: true) 30 | $UserModelCopyWith get copyWith => 31 | throw _privateConstructorUsedError; 32 | } 33 | 34 | /// @nodoc 35 | abstract class $UserModelCopyWith<$Res> { 36 | factory $UserModelCopyWith(UserModel value, $Res Function(UserModel) then) = 37 | _$UserModelCopyWithImpl<$Res>; 38 | $Res call({String? uuid, String? password, String email}); 39 | } 40 | 41 | /// @nodoc 42 | class _$UserModelCopyWithImpl<$Res> implements $UserModelCopyWith<$Res> { 43 | _$UserModelCopyWithImpl(this._value, this._then); 44 | 45 | final UserModel _value; 46 | // ignore: unused_field 47 | final $Res Function(UserModel) _then; 48 | 49 | @override 50 | $Res call({ 51 | Object? uuid = freezed, 52 | Object? password = freezed, 53 | Object? email = freezed, 54 | }) { 55 | return _then(_value.copyWith( 56 | uuid: uuid == freezed 57 | ? _value.uuid 58 | : uuid // ignore: cast_nullable_to_non_nullable 59 | as String?, 60 | password: password == freezed 61 | ? _value.password 62 | : password // ignore: cast_nullable_to_non_nullable 63 | as String?, 64 | email: email == freezed 65 | ? _value.email 66 | : email // ignore: cast_nullable_to_non_nullable 67 | as String, 68 | )); 69 | } 70 | } 71 | 72 | /// @nodoc 73 | abstract class _$$_UserModelCopyWith<$Res> implements $UserModelCopyWith<$Res> { 74 | factory _$$_UserModelCopyWith( 75 | _$_UserModel value, $Res Function(_$_UserModel) then) = 76 | __$$_UserModelCopyWithImpl<$Res>; 77 | @override 78 | $Res call({String? uuid, String? password, String email}); 79 | } 80 | 81 | /// @nodoc 82 | class __$$_UserModelCopyWithImpl<$Res> extends _$UserModelCopyWithImpl<$Res> 83 | implements _$$_UserModelCopyWith<$Res> { 84 | __$$_UserModelCopyWithImpl( 85 | _$_UserModel _value, $Res Function(_$_UserModel) _then) 86 | : super(_value, (v) => _then(v as _$_UserModel)); 87 | 88 | @override 89 | _$_UserModel get _value => super._value as _$_UserModel; 90 | 91 | @override 92 | $Res call({ 93 | Object? uuid = freezed, 94 | Object? password = freezed, 95 | Object? email = freezed, 96 | }) { 97 | return _then(_$_UserModel( 98 | uuid: uuid == freezed 99 | ? _value.uuid 100 | : uuid // ignore: cast_nullable_to_non_nullable 101 | as String?, 102 | password: password == freezed 103 | ? _value.password 104 | : password // ignore: cast_nullable_to_non_nullable 105 | as String?, 106 | email: email == freezed 107 | ? _value.email 108 | : email // ignore: cast_nullable_to_non_nullable 109 | as String, 110 | )); 111 | } 112 | } 113 | 114 | /// @nodoc 115 | 116 | @JsonSerializable(explicitToJson: true) 117 | class _$_UserModel implements _UserModel { 118 | const _$_UserModel({this.uuid, this.password, required this.email}); 119 | 120 | factory _$_UserModel.fromJson(Map json) => 121 | _$$_UserModelFromJson(json); 122 | 123 | @override 124 | final String? uuid; 125 | @override 126 | final String? password; 127 | // @JsonKey(name: 'address', fromJson: addressFromJson) String? address, 128 | @override 129 | final String email; 130 | 131 | @override 132 | String toString() { 133 | return 'UserModel(uuid: $uuid, password: $password, email: $email)'; 134 | } 135 | 136 | @override 137 | bool operator ==(dynamic other) { 138 | return identical(this, other) || 139 | (other.runtimeType == runtimeType && 140 | other is _$_UserModel && 141 | const DeepCollectionEquality().equals(other.uuid, uuid) && 142 | const DeepCollectionEquality().equals(other.password, password) && 143 | const DeepCollectionEquality().equals(other.email, email)); 144 | } 145 | 146 | @JsonKey(ignore: true) 147 | @override 148 | int get hashCode => Object.hash( 149 | runtimeType, 150 | const DeepCollectionEquality().hash(uuid), 151 | const DeepCollectionEquality().hash(password), 152 | const DeepCollectionEquality().hash(email)); 153 | 154 | @JsonKey(ignore: true) 155 | @override 156 | _$$_UserModelCopyWith<_$_UserModel> get copyWith => 157 | __$$_UserModelCopyWithImpl<_$_UserModel>(this, _$identity); 158 | 159 | @override 160 | Map toJson() { 161 | return _$$_UserModelToJson( 162 | this, 163 | ); 164 | } 165 | } 166 | 167 | abstract class _UserModel implements UserModel { 168 | const factory _UserModel( 169 | {final String? uuid, 170 | final String? password, 171 | required final String email}) = _$_UserModel; 172 | 173 | factory _UserModel.fromJson(Map json) = 174 | _$_UserModel.fromJson; 175 | 176 | @override 177 | String? get uuid; 178 | @override 179 | String? get password; 180 | @override // @JsonKey(name: 'address', fromJson: addressFromJson) String? address, 181 | String get email; 182 | @override 183 | @JsonKey(ignore: true) 184 | _$$_UserModelCopyWith<_$_UserModel> get copyWith => 185 | throw _privateConstructorUsedError; 186 | } 187 | -------------------------------------------------------------------------------- /lib/src/features/auth/views/login_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | 4 | import '../../../core/data_state.dart'; 5 | import '../../../core/form_validator.dart'; 6 | import '../../../core/providers.dart'; 7 | import '../../../core/styles.dart'; 8 | import '../../../core/widgets/loading_widget.dart'; 9 | 10 | class LoginView extends ConsumerStatefulWidget { 11 | const LoginView({Key? key}) : super(key: key); 12 | 13 | @override 14 | LoginViewState createState() => LoginViewState(); 15 | } 16 | 17 | class LoginViewState extends ConsumerState { 18 | final _formKey = GlobalKey(); 19 | final _emailController = TextEditingController(); 20 | final _passwordController = TextEditingController(); 21 | 22 | bool _hidePassword = true; 23 | 24 | void _handleUserLogin() { 25 | if (_formKey.currentState!.validate()) { 26 | _formKey.currentState!.save(); 27 | 28 | Map credentials = { 29 | 'email': _emailController.text, 30 | 'password': _passwordController.text, 31 | }; 32 | 33 | ref.read(authNotifier.notifier).login(credentials); 34 | } 35 | } 36 | 37 | void _togglePasswordVisibility() { 38 | setState(() { 39 | _hidePassword = !_hidePassword; 40 | }); 41 | } 42 | 43 | @override 44 | Widget build(BuildContext context) { 45 | final authState = ref.watch(authNotifier); 46 | 47 | ref.listen(authNotifier, (_, state) { 48 | state.maybeWhen( 49 | success: (user) => Navigator.pushReplacementNamed( 50 | context, 51 | '/request-list', 52 | ), 53 | error: (err, _) { 54 | ScaffoldMessenger.of(context).showSnackBar( 55 | SnackBar( 56 | content: Text(err), 57 | backgroundColor: Colors.red, 58 | ), 59 | ); 60 | }, 61 | orElse: () {}, 62 | ); 63 | }); 64 | 65 | return Scaffold( 66 | backgroundColor: const Color(0xFFFAFAFA), 67 | appBar: AppBar( 68 | elevation: 2.0, 69 | title: const Text( 70 | 'Login', 71 | style: TextStyle( 72 | color: Colors.white, 73 | fontWeight: FontWeight.bold, 74 | fontSize: 24, 75 | ), 76 | ), 77 | centerTitle: true, 78 | ), 79 | body: Form( 80 | key: _formKey, 81 | child: ListView( 82 | padding: const EdgeInsets.all(16), 83 | children: [ 84 | Container( 85 | height: MediaQuery.of(context).size.height * 0.25, 86 | decoration: BoxDecoration( 87 | color: Theme.of(context).primaryColor, 88 | borderRadius: BorderRadius.circular(10), 89 | ), 90 | child: const Center( 91 | child: Icon(Icons.lock_open, size: 64, color: Colors.white), 92 | ), 93 | ), 94 | const SizedBox(height: 24), 95 | const Text( 96 | "Email address", 97 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 98 | ), 99 | const SizedBox(height: 8), 100 | TextFormField( 101 | controller: _emailController, 102 | keyboardType: TextInputType.emailAddress, 103 | decoration: const InputDecoration( 104 | hintText: 'yourname@email.com', 105 | labelStyle: TextStyle(color: Colors.grey), 106 | enabledBorder: AppInputBorder.enabledBorder, 107 | focusedBorder: AppInputBorder.focusedBorder, 108 | errorBorder: AppInputBorder.errorBorder, 109 | focusedErrorBorder: AppInputBorder.focusedErrorBorder, 110 | contentPadding: EdgeInsets.all(10), 111 | ), 112 | validator: FormValidator.validateEmail, 113 | ), 114 | const SizedBox(height: 16), 115 | const Text( 116 | "Password", 117 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 118 | ), 119 | const SizedBox(height: 8), 120 | TextFormField( 121 | controller: _passwordController, 122 | keyboardType: TextInputType.visiblePassword, 123 | obscureText: _hidePassword, 124 | decoration: InputDecoration( 125 | hintText: '*******************', 126 | labelStyle: const TextStyle(color: Colors.grey), 127 | enabledBorder: AppInputBorder.enabledBorder, 128 | focusedBorder: AppInputBorder.focusedBorder, 129 | errorBorder: AppInputBorder.errorBorder, 130 | focusedErrorBorder: AppInputBorder.focusedErrorBorder, 131 | contentPadding: const EdgeInsets.all(10), 132 | suffixIcon: IconButton( 133 | icon: Icon( 134 | _hidePassword ? Icons.visibility : Icons.visibility_off, 135 | color: Colors.grey, 136 | ), 137 | onPressed: _togglePasswordVisibility, 138 | ), 139 | ), 140 | validator: FormValidator.validatePassword, 141 | ), 142 | const SizedBox(height: 20), 143 | SizedBox( 144 | width: double.infinity, 145 | child: ElevatedButton( 146 | onPressed: authState.maybeWhen( 147 | loading: () => null, 148 | orElse: () => _handleUserLogin, 149 | ), 150 | style: ElevatedButton.styleFrom( 151 | elevation: 0, 152 | shape: RoundedRectangleBorder( 153 | borderRadius: BorderRadius.circular(10), 154 | ), 155 | padding: const EdgeInsets.symmetric(vertical: 16), 156 | ), 157 | child: authState.maybeWhen( 158 | loading: () => const LoadingWidget(), 159 | orElse: () => const Text('LOGIN'), 160 | ), 161 | ), 162 | ), 163 | const Padding( 164 | padding: EdgeInsets.only(left: 16, right: 16), 165 | child: Divider(height: 64), 166 | ), 167 | Row( 168 | mainAxisAlignment: MainAxisAlignment.end, 169 | children: const [ 170 | Text("Don't have an account?"), 171 | ], 172 | ), 173 | const SizedBox(height: 8), 174 | SizedBox( 175 | width: double.infinity, 176 | child: OutlinedButton( 177 | onPressed: () => Navigator.pushNamed(context, '/register'), 178 | style: ElevatedButton.styleFrom( 179 | elevation: 0, 180 | shape: RoundedRectangleBorder( 181 | borderRadius: BorderRadius.circular(10), 182 | ), 183 | padding: const EdgeInsets.symmetric(vertical: 16), 184 | ), 185 | child: const Text('CREATE ACCOUNT'), 186 | ), 187 | ), 188 | ], 189 | ), 190 | ), 191 | ); 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /lib/src/features/estimates/models/quote_model.freezed.dart: -------------------------------------------------------------------------------- 1 | // coverage:ignore-file 2 | // GENERATED CODE - DO NOT MODIFY BY HAND 3 | // ignore_for_file: type=lint 4 | // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target 5 | 6 | part of 'quote_model.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | T _$identity(T value) => value; 13 | 14 | final _privateConstructorUsedError = UnsupportedError( 15 | 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); 16 | 17 | Quote _$QuoteFromJson(Map json) { 18 | return _Quote.fromJson(json); 19 | } 20 | 21 | /// @nodoc 22 | mixin _$Quote { 23 | int? get id => throw _privateConstructorUsedError; 24 | @JsonKey(name: 'product_name') 25 | String get productName => throw _privateConstructorUsedError; 26 | String get description => throw _privateConstructorUsedError; 27 | @JsonKey(name: 'product_link') 28 | String get productLink => throw _privateConstructorUsedError; 29 | int get quantity => throw _privateConstructorUsedError; 30 | @JsonKey(name: 'created_at') 31 | DateTime? get createdAt => throw _privateConstructorUsedError; 32 | 33 | Map toJson() => throw _privateConstructorUsedError; 34 | @JsonKey(ignore: true) 35 | $QuoteCopyWith get copyWith => throw _privateConstructorUsedError; 36 | } 37 | 38 | /// @nodoc 39 | abstract class $QuoteCopyWith<$Res> { 40 | factory $QuoteCopyWith(Quote value, $Res Function(Quote) then) = 41 | _$QuoteCopyWithImpl<$Res>; 42 | $Res call( 43 | {int? id, 44 | @JsonKey(name: 'product_name') String productName, 45 | String description, 46 | @JsonKey(name: 'product_link') String productLink, 47 | int quantity, 48 | @JsonKey(name: 'created_at') DateTime? createdAt}); 49 | } 50 | 51 | /// @nodoc 52 | class _$QuoteCopyWithImpl<$Res> implements $QuoteCopyWith<$Res> { 53 | _$QuoteCopyWithImpl(this._value, this._then); 54 | 55 | final Quote _value; 56 | // ignore: unused_field 57 | final $Res Function(Quote) _then; 58 | 59 | @override 60 | $Res call({ 61 | Object? id = freezed, 62 | Object? productName = freezed, 63 | Object? description = freezed, 64 | Object? productLink = freezed, 65 | Object? quantity = freezed, 66 | Object? createdAt = freezed, 67 | }) { 68 | return _then(_value.copyWith( 69 | id: id == freezed 70 | ? _value.id 71 | : id // ignore: cast_nullable_to_non_nullable 72 | as int?, 73 | productName: productName == freezed 74 | ? _value.productName 75 | : productName // ignore: cast_nullable_to_non_nullable 76 | as String, 77 | description: description == freezed 78 | ? _value.description 79 | : description // ignore: cast_nullable_to_non_nullable 80 | as String, 81 | productLink: productLink == freezed 82 | ? _value.productLink 83 | : productLink // ignore: cast_nullable_to_non_nullable 84 | as String, 85 | quantity: quantity == freezed 86 | ? _value.quantity 87 | : quantity // ignore: cast_nullable_to_non_nullable 88 | as int, 89 | createdAt: createdAt == freezed 90 | ? _value.createdAt 91 | : createdAt // ignore: cast_nullable_to_non_nullable 92 | as DateTime?, 93 | )); 94 | } 95 | } 96 | 97 | /// @nodoc 98 | abstract class _$$_QuoteCopyWith<$Res> implements $QuoteCopyWith<$Res> { 99 | factory _$$_QuoteCopyWith(_$_Quote value, $Res Function(_$_Quote) then) = 100 | __$$_QuoteCopyWithImpl<$Res>; 101 | @override 102 | $Res call( 103 | {int? id, 104 | @JsonKey(name: 'product_name') String productName, 105 | String description, 106 | @JsonKey(name: 'product_link') String productLink, 107 | int quantity, 108 | @JsonKey(name: 'created_at') DateTime? createdAt}); 109 | } 110 | 111 | /// @nodoc 112 | class __$$_QuoteCopyWithImpl<$Res> extends _$QuoteCopyWithImpl<$Res> 113 | implements _$$_QuoteCopyWith<$Res> { 114 | __$$_QuoteCopyWithImpl(_$_Quote _value, $Res Function(_$_Quote) _then) 115 | : super(_value, (v) => _then(v as _$_Quote)); 116 | 117 | @override 118 | _$_Quote get _value => super._value as _$_Quote; 119 | 120 | @override 121 | $Res call({ 122 | Object? id = freezed, 123 | Object? productName = freezed, 124 | Object? description = freezed, 125 | Object? productLink = freezed, 126 | Object? quantity = freezed, 127 | Object? createdAt = freezed, 128 | }) { 129 | return _then(_$_Quote( 130 | id: id == freezed 131 | ? _value.id 132 | : id // ignore: cast_nullable_to_non_nullable 133 | as int?, 134 | productName: productName == freezed 135 | ? _value.productName 136 | : productName // ignore: cast_nullable_to_non_nullable 137 | as String, 138 | description: description == freezed 139 | ? _value.description 140 | : description // ignore: cast_nullable_to_non_nullable 141 | as String, 142 | productLink: productLink == freezed 143 | ? _value.productLink 144 | : productLink // ignore: cast_nullable_to_non_nullable 145 | as String, 146 | quantity: quantity == freezed 147 | ? _value.quantity 148 | : quantity // ignore: cast_nullable_to_non_nullable 149 | as int, 150 | createdAt: createdAt == freezed 151 | ? _value.createdAt 152 | : createdAt // ignore: cast_nullable_to_non_nullable 153 | as DateTime?, 154 | )); 155 | } 156 | } 157 | 158 | /// @nodoc 159 | @JsonSerializable() 160 | class _$_Quote implements _Quote { 161 | const _$_Quote( 162 | {this.id, 163 | @JsonKey(name: 'product_name') required this.productName, 164 | required this.description, 165 | @JsonKey(name: 'product_link') required this.productLink, 166 | required this.quantity, 167 | @JsonKey(name: 'created_at') this.createdAt}); 168 | 169 | factory _$_Quote.fromJson(Map json) => 170 | _$$_QuoteFromJson(json); 171 | 172 | @override 173 | final int? id; 174 | @override 175 | @JsonKey(name: 'product_name') 176 | final String productName; 177 | @override 178 | final String description; 179 | @override 180 | @JsonKey(name: 'product_link') 181 | final String productLink; 182 | @override 183 | final int quantity; 184 | @override 185 | @JsonKey(name: 'created_at') 186 | final DateTime? createdAt; 187 | 188 | @override 189 | String toString() { 190 | return 'Quote(id: $id, productName: $productName, description: $description, productLink: $productLink, quantity: $quantity, createdAt: $createdAt)'; 191 | } 192 | 193 | @override 194 | bool operator ==(dynamic other) { 195 | return identical(this, other) || 196 | (other.runtimeType == runtimeType && 197 | other is _$_Quote && 198 | const DeepCollectionEquality().equals(other.id, id) && 199 | const DeepCollectionEquality() 200 | .equals(other.productName, productName) && 201 | const DeepCollectionEquality() 202 | .equals(other.description, description) && 203 | const DeepCollectionEquality() 204 | .equals(other.productLink, productLink) && 205 | const DeepCollectionEquality().equals(other.quantity, quantity) && 206 | const DeepCollectionEquality().equals(other.createdAt, createdAt)); 207 | } 208 | 209 | @JsonKey(ignore: true) 210 | @override 211 | int get hashCode => Object.hash( 212 | runtimeType, 213 | const DeepCollectionEquality().hash(id), 214 | const DeepCollectionEquality().hash(productName), 215 | const DeepCollectionEquality().hash(description), 216 | const DeepCollectionEquality().hash(productLink), 217 | const DeepCollectionEquality().hash(quantity), 218 | const DeepCollectionEquality().hash(createdAt)); 219 | 220 | @JsonKey(ignore: true) 221 | @override 222 | _$$_QuoteCopyWith<_$_Quote> get copyWith => 223 | __$$_QuoteCopyWithImpl<_$_Quote>(this, _$identity); 224 | 225 | @override 226 | Map toJson() { 227 | return _$$_QuoteToJson( 228 | this, 229 | ); 230 | } 231 | } 232 | 233 | abstract class _Quote implements Quote { 234 | const factory _Quote( 235 | {final int? id, 236 | @JsonKey(name: 'product_name') required final String productName, 237 | required final String description, 238 | @JsonKey(name: 'product_link') required final String productLink, 239 | required final int quantity, 240 | @JsonKey(name: 'created_at') final DateTime? createdAt}) = _$_Quote; 241 | 242 | factory _Quote.fromJson(Map json) = _$_Quote.fromJson; 243 | 244 | @override 245 | int? get id; 246 | @override 247 | @JsonKey(name: 'product_name') 248 | String get productName; 249 | @override 250 | String get description; 251 | @override 252 | @JsonKey(name: 'product_link') 253 | String get productLink; 254 | @override 255 | int get quantity; 256 | @override 257 | @JsonKey(name: 'created_at') 258 | DateTime? get createdAt; 259 | @override 260 | @JsonKey(ignore: true) 261 | _$$_QuoteCopyWith<_$_Quote> get copyWith => 262 | throw _privateConstructorUsedError; 263 | } 264 | -------------------------------------------------------------------------------- /lib/src/features/auth/views/register_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | 5 | import '../../../core/app_router.dart'; 6 | import '../../../core/data_state.dart'; 7 | import '../../../core/form_validator.dart'; 8 | import '../../../core/providers.dart'; 9 | import '../../../core/styles.dart'; 10 | import '../../../core/widgets/loading_widget.dart'; 11 | 12 | class RegisterView extends ConsumerStatefulWidget { 13 | const RegisterView({Key? key}) : super(key: key); 14 | 15 | @override 16 | RegisterViewState createState() => RegisterViewState(); 17 | } 18 | 19 | class RegisterViewState extends ConsumerState { 20 | final _formKey = GlobalKey(); 21 | final _fullnameController = TextEditingController(); 22 | final _emailController = TextEditingController(); 23 | final _passwordController = TextEditingController(); 24 | final _passwordConfirmController = TextEditingController(); 25 | final _addressController = TextEditingController(); 26 | 27 | bool _hidePassword = true; 28 | bool _hidePasswordConfirm = true; 29 | 30 | void _handleUserRegistration() { 31 | if (_formKey.currentState!.validate()) { 32 | _formKey.currentState!.save(); 33 | 34 | final Map userData = { 35 | 'email': _emailController.text, 36 | 'password': _passwordController.text, 37 | 'data': { 38 | 'fullname': _fullnameController.text, 39 | 'address': _addressController.text, 40 | }, 41 | }; 42 | 43 | ref.read(authNotifier.notifier).register(userData); 44 | } 45 | } 46 | 47 | void _togglePasswordVisibility() { 48 | setState(() { 49 | _hidePassword = !_hidePassword; 50 | }); 51 | } 52 | 53 | void _togglePasswordConfirmVisibility() { 54 | setState(() { 55 | _hidePasswordConfirm = !_hidePasswordConfirm; 56 | }); 57 | } 58 | 59 | @override 60 | Widget build(BuildContext context) { 61 | ref.listen(authNotifier, (_, state) { 62 | state.maybeWhen( 63 | success: (user) { 64 | ScaffoldMessenger.of(context).showSnackBar( 65 | const SnackBar( 66 | content: Text('Registration successful. Please login.'), 67 | backgroundColor: Colors.green, 68 | ), 69 | ); 70 | context.goNamed(AppRoutes.login.name); 71 | }, 72 | error: (err, _) { 73 | ScaffoldMessenger.of(context).showSnackBar( 74 | SnackBar( 75 | content: Text(err), 76 | backgroundColor: Colors.red, 77 | ), 78 | ); 79 | }, 80 | orElse: () {}, 81 | ); 82 | }); 83 | 84 | final authState = ref.watch(authNotifier); 85 | 86 | return Scaffold( 87 | backgroundColor: const Color(0xFFFAFAFA), 88 | appBar: AppBar( 89 | elevation: 2.0, 90 | title: const Text( 91 | 'Register', 92 | style: TextStyle( 93 | color: Colors.white, 94 | fontWeight: FontWeight.bold, 95 | fontSize: 24, 96 | ), 97 | ), 98 | centerTitle: true, 99 | ), 100 | body: Form( 101 | key: _formKey, 102 | child: ListView( 103 | padding: const EdgeInsets.all(16), 104 | children: [ 105 | const SizedBox(height: 16), 106 | const Text( 107 | "Fullname", 108 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 109 | ), 110 | const SizedBox(height: 8), 111 | TextFormField( 112 | controller: _fullnameController, 113 | decoration: const InputDecoration( 114 | hintText: 'Enter your fullname', 115 | labelStyle: TextStyle(color: Colors.grey), 116 | enabledBorder: AppInputBorder.enabledBorder, 117 | focusedBorder: AppInputBorder.focusedBorder, 118 | errorBorder: AppInputBorder.errorBorder, 119 | focusedErrorBorder: AppInputBorder.focusedErrorBorder, 120 | contentPadding: EdgeInsets.all(10), 121 | ), 122 | validator: FormValidator.validateFullName, 123 | ), 124 | const SizedBox(height: 16), 125 | const Text( 126 | "Email address", 127 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 128 | ), 129 | const SizedBox(height: 8), 130 | TextFormField( 131 | controller: _emailController, 132 | keyboardType: TextInputType.emailAddress, 133 | decoration: const InputDecoration( 134 | hintText: 'yourname@email.com', 135 | labelStyle: TextStyle(color: Colors.grey), 136 | enabledBorder: AppInputBorder.enabledBorder, 137 | focusedBorder: AppInputBorder.focusedBorder, 138 | errorBorder: AppInputBorder.errorBorder, 139 | focusedErrorBorder: AppInputBorder.focusedErrorBorder, 140 | contentPadding: EdgeInsets.all(10), 141 | ), 142 | validator: FormValidator.validateEmail, 143 | ), 144 | const SizedBox(height: 16), 145 | const Text( 146 | "Password", 147 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 148 | ), 149 | const SizedBox(height: 8), 150 | TextFormField( 151 | controller: _passwordController, 152 | keyboardType: TextInputType.visiblePassword, 153 | obscureText: _hidePassword, 154 | decoration: InputDecoration( 155 | hintText: '*******************', 156 | labelStyle: const TextStyle(color: Colors.grey), 157 | enabledBorder: AppInputBorder.enabledBorder, 158 | focusedBorder: AppInputBorder.focusedBorder, 159 | errorBorder: AppInputBorder.errorBorder, 160 | focusedErrorBorder: AppInputBorder.focusedErrorBorder, 161 | contentPadding: const EdgeInsets.all(10), 162 | suffixIcon: IconButton( 163 | icon: Icon( 164 | _hidePassword ? Icons.visibility_off : Icons.visibility, 165 | ), 166 | onPressed: _togglePasswordVisibility, 167 | ), 168 | ), 169 | validator: FormValidator.validatePassword, 170 | ), 171 | const SizedBox(height: 16), 172 | const Text( 173 | "Password confirmation", 174 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 175 | ), 176 | const SizedBox(height: 8), 177 | TextFormField( 178 | controller: _passwordConfirmController, 179 | keyboardType: TextInputType.visiblePassword, 180 | obscureText: _hidePasswordConfirm, 181 | decoration: InputDecoration( 182 | hintText: '*******************', 183 | labelStyle: const TextStyle(color: Colors.grey), 184 | enabledBorder: AppInputBorder.enabledBorder, 185 | focusedBorder: AppInputBorder.focusedBorder, 186 | errorBorder: AppInputBorder.errorBorder, 187 | focusedErrorBorder: AppInputBorder.focusedErrorBorder, 188 | contentPadding: const EdgeInsets.all(10), 189 | suffixIcon: IconButton( 190 | icon: Icon( 191 | _hidePasswordConfirm 192 | ? Icons.visibility_off 193 | : Icons.visibility, 194 | ), 195 | onPressed: _togglePasswordConfirmVisibility, 196 | ), 197 | ), 198 | validator: (value) => FormValidator.validatePasswordConfirmation( 199 | value, 200 | _passwordController.text, 201 | ), 202 | ), 203 | const SizedBox(height: 16), 204 | const Text( 205 | "Address", 206 | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), 207 | ), 208 | const SizedBox(height: 8), 209 | TextFormField( 210 | controller: _addressController, 211 | keyboardType: TextInputType.streetAddress, 212 | decoration: const InputDecoration( 213 | hintText: 'Enter your address', 214 | labelStyle: TextStyle(color: Colors.grey), 215 | enabledBorder: AppInputBorder.enabledBorder, 216 | focusedBorder: AppInputBorder.focusedBorder, 217 | errorBorder: AppInputBorder.errorBorder, 218 | focusedErrorBorder: AppInputBorder.focusedErrorBorder, 219 | contentPadding: EdgeInsets.all(10), 220 | ), 221 | ), 222 | const SizedBox(height: 20), 223 | SizedBox( 224 | width: double.infinity, 225 | child: ElevatedButton( 226 | onPressed: authState.maybeWhen( 227 | loading: () => null, 228 | orElse: () => _handleUserRegistration, 229 | ), 230 | style: ElevatedButton.styleFrom( 231 | elevation: 0, 232 | shape: RoundedRectangleBorder( 233 | borderRadius: BorderRadius.circular(10), 234 | ), 235 | padding: const EdgeInsets.symmetric(vertical: 16), 236 | ), 237 | child: authState.maybeWhen( 238 | loading: () => const LoadingWidget(), 239 | orElse: () => const Text('REGISTER'), 240 | ), 241 | ), 242 | ), 243 | const Padding( 244 | padding: EdgeInsets.only(left: 16, right: 16), 245 | child: Divider(height: 64), 246 | ), 247 | Row( 248 | mainAxisAlignment: MainAxisAlignment.end, 249 | children: const [ 250 | Text("You already have an account?"), 251 | ], 252 | ), 253 | const SizedBox(height: 8), 254 | SizedBox( 255 | width: double.infinity, 256 | child: OutlinedButton( 257 | onPressed: () => Navigator.pop(context), 258 | style: ElevatedButton.styleFrom( 259 | elevation: 0, 260 | shape: RoundedRectangleBorder( 261 | borderRadius: BorderRadius.circular(10), 262 | ), 263 | padding: const EdgeInsets.symmetric(vertical: 16), 264 | ), 265 | child: const Text('LOGIN'), 266 | ), 267 | ), 268 | ], 269 | ), 270 | ), 271 | ); 272 | } 273 | } 274 | -------------------------------------------------------------------------------- /lib/src/core/data_state.freezed.dart: -------------------------------------------------------------------------------- 1 | // coverage:ignore-file 2 | // GENERATED CODE - DO NOT MODIFY BY HAND 3 | // ignore_for_file: type=lint 4 | // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target 5 | 6 | part of 'data_state.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | T _$identity(T value) => value; 13 | 14 | final _privateConstructorUsedError = UnsupportedError( 15 | 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); 16 | 17 | /// @nodoc 18 | mixin _$DataState { 19 | @optionalTypeArgs 20 | TResult when({ 21 | required TResult Function() initial, 22 | required TResult Function() loading, 23 | required TResult Function(T data) success, 24 | required TResult Function(String message, StackTrace? stackTrace) error, 25 | }) => 26 | throw _privateConstructorUsedError; 27 | @optionalTypeArgs 28 | TResult? whenOrNull({ 29 | TResult Function()? initial, 30 | TResult Function()? loading, 31 | TResult Function(T data)? success, 32 | TResult Function(String message, StackTrace? stackTrace)? error, 33 | }) => 34 | throw _privateConstructorUsedError; 35 | @optionalTypeArgs 36 | TResult maybeWhen({ 37 | TResult Function()? initial, 38 | TResult Function()? loading, 39 | TResult Function(T data)? success, 40 | TResult Function(String message, StackTrace? stackTrace)? error, 41 | required TResult orElse(), 42 | }) => 43 | throw _privateConstructorUsedError; 44 | @optionalTypeArgs 45 | TResult map({ 46 | required TResult Function(_Initial value) initial, 47 | required TResult Function(_Loading value) loading, 48 | required TResult Function(_Success value) success, 49 | required TResult Function(_Error value) error, 50 | }) => 51 | throw _privateConstructorUsedError; 52 | @optionalTypeArgs 53 | TResult? mapOrNull({ 54 | TResult Function(_Initial value)? initial, 55 | TResult Function(_Loading value)? loading, 56 | TResult Function(_Success value)? success, 57 | TResult Function(_Error value)? error, 58 | }) => 59 | throw _privateConstructorUsedError; 60 | @optionalTypeArgs 61 | TResult maybeMap({ 62 | TResult Function(_Initial value)? initial, 63 | TResult Function(_Loading value)? loading, 64 | TResult Function(_Success value)? success, 65 | TResult Function(_Error value)? error, 66 | required TResult orElse(), 67 | }) => 68 | throw _privateConstructorUsedError; 69 | } 70 | 71 | /// @nodoc 72 | abstract class $DataStateCopyWith { 73 | factory $DataStateCopyWith( 74 | DataState value, $Res Function(DataState) then) = 75 | _$DataStateCopyWithImpl; 76 | } 77 | 78 | /// @nodoc 79 | class _$DataStateCopyWithImpl implements $DataStateCopyWith { 80 | _$DataStateCopyWithImpl(this._value, this._then); 81 | 82 | final DataState _value; 83 | // ignore: unused_field 84 | final $Res Function(DataState) _then; 85 | } 86 | 87 | /// @nodoc 88 | abstract class _$$_InitialCopyWith { 89 | factory _$$_InitialCopyWith( 90 | _$_Initial value, $Res Function(_$_Initial) then) = 91 | __$$_InitialCopyWithImpl; 92 | } 93 | 94 | /// @nodoc 95 | class __$$_InitialCopyWithImpl extends _$DataStateCopyWithImpl 96 | implements _$$_InitialCopyWith { 97 | __$$_InitialCopyWithImpl( 98 | _$_Initial _value, $Res Function(_$_Initial) _then) 99 | : super(_value, (v) => _then(v as _$_Initial)); 100 | 101 | @override 102 | _$_Initial get _value => super._value as _$_Initial; 103 | } 104 | 105 | /// @nodoc 106 | 107 | class _$_Initial implements _Initial { 108 | const _$_Initial(); 109 | 110 | @override 111 | String toString() { 112 | return 'DataState<$T>.initial()'; 113 | } 114 | 115 | @override 116 | bool operator ==(dynamic other) { 117 | return identical(this, other) || 118 | (other.runtimeType == runtimeType && other is _$_Initial); 119 | } 120 | 121 | @override 122 | int get hashCode => runtimeType.hashCode; 123 | 124 | @override 125 | @optionalTypeArgs 126 | TResult when({ 127 | required TResult Function() initial, 128 | required TResult Function() loading, 129 | required TResult Function(T data) success, 130 | required TResult Function(String message, StackTrace? stackTrace) error, 131 | }) { 132 | return initial(); 133 | } 134 | 135 | @override 136 | @optionalTypeArgs 137 | TResult? whenOrNull({ 138 | TResult Function()? initial, 139 | TResult Function()? loading, 140 | TResult Function(T data)? success, 141 | TResult Function(String message, StackTrace? stackTrace)? error, 142 | }) { 143 | return initial?.call(); 144 | } 145 | 146 | @override 147 | @optionalTypeArgs 148 | TResult maybeWhen({ 149 | TResult Function()? initial, 150 | TResult Function()? loading, 151 | TResult Function(T data)? success, 152 | TResult Function(String message, StackTrace? stackTrace)? error, 153 | required TResult orElse(), 154 | }) { 155 | if (initial != null) { 156 | return initial(); 157 | } 158 | return orElse(); 159 | } 160 | 161 | @override 162 | @optionalTypeArgs 163 | TResult map({ 164 | required TResult Function(_Initial value) initial, 165 | required TResult Function(_Loading value) loading, 166 | required TResult Function(_Success value) success, 167 | required TResult Function(_Error value) error, 168 | }) { 169 | return initial(this); 170 | } 171 | 172 | @override 173 | @optionalTypeArgs 174 | TResult? mapOrNull({ 175 | TResult Function(_Initial value)? initial, 176 | TResult Function(_Loading value)? loading, 177 | TResult Function(_Success value)? success, 178 | TResult Function(_Error value)? error, 179 | }) { 180 | return initial?.call(this); 181 | } 182 | 183 | @override 184 | @optionalTypeArgs 185 | TResult maybeMap({ 186 | TResult Function(_Initial value)? initial, 187 | TResult Function(_Loading value)? loading, 188 | TResult Function(_Success value)? success, 189 | TResult Function(_Error value)? error, 190 | required TResult orElse(), 191 | }) { 192 | if (initial != null) { 193 | return initial(this); 194 | } 195 | return orElse(); 196 | } 197 | } 198 | 199 | abstract class _Initial implements DataState { 200 | const factory _Initial() = _$_Initial; 201 | } 202 | 203 | /// @nodoc 204 | abstract class _$$_LoadingCopyWith { 205 | factory _$$_LoadingCopyWith( 206 | _$_Loading value, $Res Function(_$_Loading) then) = 207 | __$$_LoadingCopyWithImpl; 208 | } 209 | 210 | /// @nodoc 211 | class __$$_LoadingCopyWithImpl extends _$DataStateCopyWithImpl 212 | implements _$$_LoadingCopyWith { 213 | __$$_LoadingCopyWithImpl( 214 | _$_Loading _value, $Res Function(_$_Loading) _then) 215 | : super(_value, (v) => _then(v as _$_Loading)); 216 | 217 | @override 218 | _$_Loading get _value => super._value as _$_Loading; 219 | } 220 | 221 | /// @nodoc 222 | 223 | class _$_Loading implements _Loading { 224 | const _$_Loading(); 225 | 226 | @override 227 | String toString() { 228 | return 'DataState<$T>.loading()'; 229 | } 230 | 231 | @override 232 | bool operator ==(dynamic other) { 233 | return identical(this, other) || 234 | (other.runtimeType == runtimeType && other is _$_Loading); 235 | } 236 | 237 | @override 238 | int get hashCode => runtimeType.hashCode; 239 | 240 | @override 241 | @optionalTypeArgs 242 | TResult when({ 243 | required TResult Function() initial, 244 | required TResult Function() loading, 245 | required TResult Function(T data) success, 246 | required TResult Function(String message, StackTrace? stackTrace) error, 247 | }) { 248 | return loading(); 249 | } 250 | 251 | @override 252 | @optionalTypeArgs 253 | TResult? whenOrNull({ 254 | TResult Function()? initial, 255 | TResult Function()? loading, 256 | TResult Function(T data)? success, 257 | TResult Function(String message, StackTrace? stackTrace)? error, 258 | }) { 259 | return loading?.call(); 260 | } 261 | 262 | @override 263 | @optionalTypeArgs 264 | TResult maybeWhen({ 265 | TResult Function()? initial, 266 | TResult Function()? loading, 267 | TResult Function(T data)? success, 268 | TResult Function(String message, StackTrace? stackTrace)? error, 269 | required TResult orElse(), 270 | }) { 271 | if (loading != null) { 272 | return loading(); 273 | } 274 | return orElse(); 275 | } 276 | 277 | @override 278 | @optionalTypeArgs 279 | TResult map({ 280 | required TResult Function(_Initial value) initial, 281 | required TResult Function(_Loading value) loading, 282 | required TResult Function(_Success value) success, 283 | required TResult Function(_Error value) error, 284 | }) { 285 | return loading(this); 286 | } 287 | 288 | @override 289 | @optionalTypeArgs 290 | TResult? mapOrNull({ 291 | TResult Function(_Initial value)? initial, 292 | TResult Function(_Loading value)? loading, 293 | TResult Function(_Success value)? success, 294 | TResult Function(_Error value)? error, 295 | }) { 296 | return loading?.call(this); 297 | } 298 | 299 | @override 300 | @optionalTypeArgs 301 | TResult maybeMap({ 302 | TResult Function(_Initial value)? initial, 303 | TResult Function(_Loading value)? loading, 304 | TResult Function(_Success value)? success, 305 | TResult Function(_Error value)? error, 306 | required TResult orElse(), 307 | }) { 308 | if (loading != null) { 309 | return loading(this); 310 | } 311 | return orElse(); 312 | } 313 | } 314 | 315 | abstract class _Loading implements DataState { 316 | const factory _Loading() = _$_Loading; 317 | } 318 | 319 | /// @nodoc 320 | abstract class _$$_SuccessCopyWith { 321 | factory _$$_SuccessCopyWith( 322 | _$_Success value, $Res Function(_$_Success) then) = 323 | __$$_SuccessCopyWithImpl; 324 | $Res call({T data}); 325 | } 326 | 327 | /// @nodoc 328 | class __$$_SuccessCopyWithImpl extends _$DataStateCopyWithImpl 329 | implements _$$_SuccessCopyWith { 330 | __$$_SuccessCopyWithImpl( 331 | _$_Success _value, $Res Function(_$_Success) _then) 332 | : super(_value, (v) => _then(v as _$_Success)); 333 | 334 | @override 335 | _$_Success get _value => super._value as _$_Success; 336 | 337 | @override 338 | $Res call({ 339 | Object? data = freezed, 340 | }) { 341 | return _then(_$_Success( 342 | data: data == freezed 343 | ? _value.data 344 | : data // ignore: cast_nullable_to_non_nullable 345 | as T, 346 | )); 347 | } 348 | } 349 | 350 | /// @nodoc 351 | 352 | class _$_Success implements _Success { 353 | const _$_Success({required this.data}); 354 | 355 | @override 356 | final T data; 357 | 358 | @override 359 | String toString() { 360 | return 'DataState<$T>.success(data: $data)'; 361 | } 362 | 363 | @override 364 | bool operator ==(dynamic other) { 365 | return identical(this, other) || 366 | (other.runtimeType == runtimeType && 367 | other is _$_Success && 368 | const DeepCollectionEquality().equals(other.data, data)); 369 | } 370 | 371 | @override 372 | int get hashCode => 373 | Object.hash(runtimeType, const DeepCollectionEquality().hash(data)); 374 | 375 | @JsonKey(ignore: true) 376 | @override 377 | _$$_SuccessCopyWith> get copyWith => 378 | __$$_SuccessCopyWithImpl>(this, _$identity); 379 | 380 | @override 381 | @optionalTypeArgs 382 | TResult when({ 383 | required TResult Function() initial, 384 | required TResult Function() loading, 385 | required TResult Function(T data) success, 386 | required TResult Function(String message, StackTrace? stackTrace) error, 387 | }) { 388 | return success(data); 389 | } 390 | 391 | @override 392 | @optionalTypeArgs 393 | TResult? whenOrNull({ 394 | TResult Function()? initial, 395 | TResult Function()? loading, 396 | TResult Function(T data)? success, 397 | TResult Function(String message, StackTrace? stackTrace)? error, 398 | }) { 399 | return success?.call(data); 400 | } 401 | 402 | @override 403 | @optionalTypeArgs 404 | TResult maybeWhen({ 405 | TResult Function()? initial, 406 | TResult Function()? loading, 407 | TResult Function(T data)? success, 408 | TResult Function(String message, StackTrace? stackTrace)? error, 409 | required TResult orElse(), 410 | }) { 411 | if (success != null) { 412 | return success(data); 413 | } 414 | return orElse(); 415 | } 416 | 417 | @override 418 | @optionalTypeArgs 419 | TResult map({ 420 | required TResult Function(_Initial value) initial, 421 | required TResult Function(_Loading value) loading, 422 | required TResult Function(_Success value) success, 423 | required TResult Function(_Error value) error, 424 | }) { 425 | return success(this); 426 | } 427 | 428 | @override 429 | @optionalTypeArgs 430 | TResult? mapOrNull({ 431 | TResult Function(_Initial value)? initial, 432 | TResult Function(_Loading value)? loading, 433 | TResult Function(_Success value)? success, 434 | TResult Function(_Error value)? error, 435 | }) { 436 | return success?.call(this); 437 | } 438 | 439 | @override 440 | @optionalTypeArgs 441 | TResult maybeMap({ 442 | TResult Function(_Initial value)? initial, 443 | TResult Function(_Loading value)? loading, 444 | TResult Function(_Success value)? success, 445 | TResult Function(_Error value)? error, 446 | required TResult orElse(), 447 | }) { 448 | if (success != null) { 449 | return success(this); 450 | } 451 | return orElse(); 452 | } 453 | } 454 | 455 | abstract class _Success implements DataState { 456 | const factory _Success({required final T data}) = _$_Success; 457 | 458 | T get data; 459 | @JsonKey(ignore: true) 460 | _$$_SuccessCopyWith> get copyWith => 461 | throw _privateConstructorUsedError; 462 | } 463 | 464 | /// @nodoc 465 | abstract class _$$_ErrorCopyWith { 466 | factory _$$_ErrorCopyWith( 467 | _$_Error value, $Res Function(_$_Error) then) = 468 | __$$_ErrorCopyWithImpl; 469 | $Res call({String message, StackTrace? stackTrace}); 470 | } 471 | 472 | /// @nodoc 473 | class __$$_ErrorCopyWithImpl extends _$DataStateCopyWithImpl 474 | implements _$$_ErrorCopyWith { 475 | __$$_ErrorCopyWithImpl(_$_Error _value, $Res Function(_$_Error) _then) 476 | : super(_value, (v) => _then(v as _$_Error)); 477 | 478 | @override 479 | _$_Error get _value => super._value as _$_Error; 480 | 481 | @override 482 | $Res call({ 483 | Object? message = freezed, 484 | Object? stackTrace = freezed, 485 | }) { 486 | return _then(_$_Error( 487 | message: message == freezed 488 | ? _value.message 489 | : message // ignore: cast_nullable_to_non_nullable 490 | as String, 491 | stackTrace: stackTrace == freezed 492 | ? _value.stackTrace 493 | : stackTrace // ignore: cast_nullable_to_non_nullable 494 | as StackTrace?, 495 | )); 496 | } 497 | } 498 | 499 | /// @nodoc 500 | 501 | class _$_Error implements _Error { 502 | const _$_Error({required this.message, this.stackTrace}); 503 | 504 | @override 505 | final String message; 506 | @override 507 | final StackTrace? stackTrace; 508 | 509 | @override 510 | String toString() { 511 | return 'DataState<$T>.error(message: $message, stackTrace: $stackTrace)'; 512 | } 513 | 514 | @override 515 | bool operator ==(dynamic other) { 516 | return identical(this, other) || 517 | (other.runtimeType == runtimeType && 518 | other is _$_Error && 519 | const DeepCollectionEquality().equals(other.message, message) && 520 | const DeepCollectionEquality() 521 | .equals(other.stackTrace, stackTrace)); 522 | } 523 | 524 | @override 525 | int get hashCode => Object.hash( 526 | runtimeType, 527 | const DeepCollectionEquality().hash(message), 528 | const DeepCollectionEquality().hash(stackTrace)); 529 | 530 | @JsonKey(ignore: true) 531 | @override 532 | _$$_ErrorCopyWith> get copyWith => 533 | __$$_ErrorCopyWithImpl>(this, _$identity); 534 | 535 | @override 536 | @optionalTypeArgs 537 | TResult when({ 538 | required TResult Function() initial, 539 | required TResult Function() loading, 540 | required TResult Function(T data) success, 541 | required TResult Function(String message, StackTrace? stackTrace) error, 542 | }) { 543 | return error(message, stackTrace); 544 | } 545 | 546 | @override 547 | @optionalTypeArgs 548 | TResult? whenOrNull({ 549 | TResult Function()? initial, 550 | TResult Function()? loading, 551 | TResult Function(T data)? success, 552 | TResult Function(String message, StackTrace? stackTrace)? error, 553 | }) { 554 | return error?.call(message, stackTrace); 555 | } 556 | 557 | @override 558 | @optionalTypeArgs 559 | TResult maybeWhen({ 560 | TResult Function()? initial, 561 | TResult Function()? loading, 562 | TResult Function(T data)? success, 563 | TResult Function(String message, StackTrace? stackTrace)? error, 564 | required TResult orElse(), 565 | }) { 566 | if (error != null) { 567 | return error(message, stackTrace); 568 | } 569 | return orElse(); 570 | } 571 | 572 | @override 573 | @optionalTypeArgs 574 | TResult map({ 575 | required TResult Function(_Initial value) initial, 576 | required TResult Function(_Loading value) loading, 577 | required TResult Function(_Success value) success, 578 | required TResult Function(_Error value) error, 579 | }) { 580 | return error(this); 581 | } 582 | 583 | @override 584 | @optionalTypeArgs 585 | TResult? mapOrNull({ 586 | TResult Function(_Initial value)? initial, 587 | TResult Function(_Loading value)? loading, 588 | TResult Function(_Success value)? success, 589 | TResult Function(_Error value)? error, 590 | }) { 591 | return error?.call(this); 592 | } 593 | 594 | @override 595 | @optionalTypeArgs 596 | TResult maybeMap({ 597 | TResult Function(_Initial value)? initial, 598 | TResult Function(_Loading value)? loading, 599 | TResult Function(_Success value)? success, 600 | TResult Function(_Error value)? error, 601 | required TResult orElse(), 602 | }) { 603 | if (error != null) { 604 | return error(this); 605 | } 606 | return orElse(); 607 | } 608 | } 609 | 610 | abstract class _Error implements DataState { 611 | const factory _Error( 612 | {required final String message, 613 | final StackTrace? stackTrace}) = _$_Error; 614 | 615 | String get message; 616 | StackTrace? get stackTrace; 617 | @JsonKey(ignore: true) 618 | _$$_ErrorCopyWith> get copyWith => 619 | throw _privateConstructorUsedError; 620 | } 621 | --------------------------------------------------------------------------------