diff --git a/.metadata b/.metadata index f0274b3..fd70cab 100644 --- a/.metadata +++ b/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: 1aafb3a8b9b0c36241c5f5b34ee914770f015818 + revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b channel: stable project_type: app diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/.gitignore b/android/.gitignore index 0a741cb..6f56801 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle b/android/app/build.gradle index 2865895..1598708 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') @@ -22,12 +22,21 @@ if (flutterVersionName == null) { } apply plugin: 'com.android.application' -apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android' +apply plugin: 'com.google.gms.google-services' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 31 + compileSdkVersion flutter.compileSdkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -39,9 +48,9 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.test_app" + applicationId "com.example.book_rent_app_chapter3" minSdkVersion 19 - targetSdkVersion 31 + targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true @@ -53,8 +62,7 @@ android { // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug minifyEnabled true - shrinkResources true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + shrinkResources false } } } @@ -65,6 +73,7 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'com.google.android.gms:play-services-ads:20.5.0' implementation platform('com.google.firebase:firebase-bom:26.1.1') implementation 'com.google.firebase:firebase-analytics' implementation 'com.android.support:multidex:1.0.3' diff --git a/android/app/google-services.json b/android/app/google-services.json index 1ca6fbb..f5dec0d 100644 --- a/android/app/google-services.json +++ b/android/app/google-services.json @@ -38,7 +38,7 @@ "client_info": { "mobilesdk_app_id": "1:212895190763:android:dd5d9477448e46123678ae", "android_client_info": { - "package_name": "com.example.test_app" + "package_name": "com.example.book_rent_app_chapter3" } }, "oauth_client": [ @@ -46,7 +46,7 @@ "client_id": "212895190763-bvvgch9rv4l6tcelqh0c6dql8sjq2ud5.apps.googleusercontent.com", "client_type": 1, "android_info": { - "package_name": "com.example.test_app", + "package_name": "com.example.book_rent_app_chapter3", "certificate_hash": "1483649d6e547013618dc7440f6d43eec2000bc1" } }, diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index e8d8693..29d2833 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.book_rent_app_chapter3"> diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 5ddc181..87bbd5d 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,14 +1,9 @@ - + package="com.example.book_rent_app_chapter3"> - - + android:name="io.flutter.embedding.android.SplashScreenDrawable" + android:resource="@drawable/launch_background" + /> @@ -45,10 +35,8 @@ - - + - diff --git a/android/app/src/main/kotlin/com/example/test_app/MainActivity.kt b/android/app/src/main/kotlin/com/example/book_rent_app_chapter3/MainActivity.kt similarity index 69% rename from android/app/src/main/kotlin/com/example/test_app/MainActivity.kt rename to android/app/src/main/kotlin/com/example/book_rent_app_chapter3/MainActivity.kt index 1340508..e27667a 100644 --- a/android/app/src/main/kotlin/com/example/test_app/MainActivity.kt +++ b/android/app/src/main/kotlin/com/example/book_rent_app_chapter3/MainActivity.kt @@ -1,4 +1,4 @@ -package com.example.test_app +package com.example.book_rent_app_chapter3 import io.flutter.embedding.android.FlutterActivity diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..3db14bb --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 1f83a33..d460d1e 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ - - diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index e8d8693..29d2833 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.book_rent_app_chapter3"> diff --git a/android/build.gradle b/android/build.gradle index 8a4fd0c..7212d0d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,21 +2,20 @@ buildscript { ext.kotlin_version = '1.6.0' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' + classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.google.gms:google-services:4.3.8' - classpath('com.android.support:multidex:1.0.3') + classpath 'com.google.gms:google-services:4.3.10' } } allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/android/gradle.properties b/android/gradle.properties index a673820..94adc3a 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -android.enableR8=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index da44bc1..bc6a58a 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/ios/.gitignore b/ios/.gitignore index e96ef60..7a7f987 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -1,3 +1,4 @@ +**/dgph *.mode1v3 *.mode2v3 *.moved-aside @@ -18,6 +19,7 @@ Flutter/App.framework Flutter/Flutter.framework Flutter/Flutter.podspec Flutter/Generated.xcconfig +Flutter/ephemeral/ Flutter/app.flx Flutter/app.zip Flutter/flutter_assets/ diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..8d4492f 100644 --- a/ios/Flutter/AppFrameworkInfo.plist +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) + en CFBundleExecutable App CFBundleIdentifier @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 9.0 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 64e9cc5..10b8127 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -127,7 +127,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -289,17 +289,12 @@ CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Flutter", + "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.testApp; + PRODUCT_BUNDLE_IDENTIFIER = com.example.bookRentAppChapter3; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -407,7 +402,8 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -421,17 +417,12 @@ CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Flutter", + "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.testApp; + PRODUCT_BUNDLE_IDENTIFIER = com.example.bookRentAppChapter3; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -448,17 +439,12 @@ CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Flutter", + "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.testApp; + PRODUCT_BUNDLE_IDENTIFIER = com.example.bookRentAppChapter3; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..c87d15a 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ - - - - + + - - CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Book Rent App Chapter3 CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -11,7 +13,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - test_app + book_rent_app_chapter3 CFBundlePackageType APPL CFBundleShortVersionString @@ -40,8 +42,6 @@ UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance - - GADApplicationIdentifier - ca-app-pub-3940256099942544~3347511713 + diff --git a/lib/QuizScreens/Question1.dart b/lib/QuizScreens/Question1.dart index 5363c9d..3a25d7a 100644 --- a/lib/QuizScreens/Question1.dart +++ b/lib/QuizScreens/Question1.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:test_app/QuizScreens/Question2.dart'; -import 'package:test_app/model/QuizDataModel.dart'; +import 'package:book_rent_app_chapter3/QuizScreens/Question2.dart'; +import 'package:book_rent_app_chapter3/model/QuizDataModel.dart'; //ignore: must_be_immutable class Question1 extends StatefulWidget { @@ -16,7 +16,7 @@ class Question1 extends StatefulWidget { } class _Question1State extends State { - String chosen; + String? chosen; bool answered = false; String option1 = 'Bold, fierce, strong headed'; String option2 = 'Lively, Extrovert, Cheerful'; diff --git a/lib/QuizScreens/Question2.dart b/lib/QuizScreens/Question2.dart index e47250d..973cd76 100644 --- a/lib/QuizScreens/Question2.dart +++ b/lib/QuizScreens/Question2.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:test_app/QuizScreens/Question3.dart'; -import 'package:test_app/model/QuizDataModel.dart'; +import 'package:book_rent_app_chapter3/QuizScreens/Question3.dart'; +import 'package:book_rent_app_chapter3/model/QuizDataModel.dart'; //ignore: must_be_immutable class Question2 extends StatefulWidget { QuizData quizData = QuizData(); - Question2({this.quizData}); + Question2({required this.quizData}); @override _Question2State createState() => _Question2State(); @@ -17,7 +17,7 @@ class Question2 extends StatefulWidget { } class _Question2State extends State { - String chosen; + String? chosen; bool answered = false; String option1 = 'Fancy restaurant'; String option2 = 'Backpacking through Europe'; diff --git a/lib/QuizScreens/Question3.dart b/lib/QuizScreens/Question3.dart index 57159fb..349d44f 100644 --- a/lib/QuizScreens/Question3.dart +++ b/lib/QuizScreens/Question3.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:test_app/QuizScreens/Question4.dart'; -import 'package:test_app/model/QuizDataModel.dart'; +import 'package:book_rent_app_chapter3/QuizScreens/Question4.dart'; +import 'package:book_rent_app_chapter3/model/QuizDataModel.dart'; //ignore: must_be_immutable class Question3 extends StatefulWidget { QuizData quizData = QuizData(); - Question3({this.quizData}); + Question3({required this.quizData}); @override _Question3State createState() => _Question3State(); @@ -17,7 +17,7 @@ class Question3 extends StatefulWidget { } class _Question3State extends State { - String chosen; + String? chosen; bool answered = false; String option1 = 'I believe in soulmates'; String option2 = 'A love triangle because I\'m\nconfused'; diff --git a/lib/QuizScreens/Question4.dart b/lib/QuizScreens/Question4.dart index 4d41196..19c7991 100644 --- a/lib/QuizScreens/Question4.dart +++ b/lib/QuizScreens/Question4.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:test_app/QuizScreens/Question5.dart'; -import 'package:test_app/model/QuizDataModel.dart'; +import 'package:book_rent_app_chapter3/QuizScreens/Question5.dart'; +import 'package:book_rent_app_chapter3/model/QuizDataModel.dart'; //ignore: must_be_immutable class Question4 extends StatefulWidget { QuizData quizData = QuizData(); - Question4({this.quizData}); + Question4({required this.quizData}); @override _Question4State createState() => _Question4State(); @@ -19,7 +19,7 @@ class Question4 extends StatefulWidget { } class _Question4State extends State { - String chosen; + String? chosen; bool answered = false; String option1 = 'Fall in love with a\nbillionaire'; String option2 = diff --git a/lib/QuizScreens/Question5.dart b/lib/QuizScreens/Question5.dart index 1774548..43deda0 100644 --- a/lib/QuizScreens/Question5.dart +++ b/lib/QuizScreens/Question5.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:test_app/QuizScreens/Question6.dart'; -import 'package:test_app/model/QuizDataModel.dart'; +import 'package:book_rent_app_chapter3/QuizScreens/Question6.dart'; +import 'package:book_rent_app_chapter3/model/QuizDataModel.dart'; //ignore: must_be_immutable class Question5 extends StatefulWidget { QuizData quizData = QuizData(); - Question5({this.quizData}); + Question5({required this.quizData}); @override _Question5State createState() => _Question5State(); @@ -18,7 +18,7 @@ class Question5 extends StatefulWidget { } class _Question5State extends State { - String chosen; + String? chosen; bool answered = false; String option1 = 'A closely knit group of 3-5 people'; String option2 = diff --git a/lib/QuizScreens/Question6.dart b/lib/QuizScreens/Question6.dart index 7f68aea..2133f29 100644 --- a/lib/QuizScreens/Question6.dart +++ b/lib/QuizScreens/Question6.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:test_app/QuizScreens/Question7.dart'; -import 'package:test_app/model/QuizDataModel.dart'; +import 'package:book_rent_app_chapter3/QuizScreens/Question7.dart'; +import 'package:book_rent_app_chapter3/model/QuizDataModel.dart'; //ignore: must_be_immutable class Question6 extends StatefulWidget { QuizData quizData = QuizData(); - Question6({this.quizData}); + Question6({required this.quizData}); @override _Question6State createState() => _Question6State(); @@ -17,7 +17,7 @@ class Question6 extends StatefulWidget { } class _Question6State extends State { - String chosen; + String? chosen; bool answered = false; String option1 = 'Sweden'; String option2 = 'A lavish castle in a dystopian world'; diff --git a/lib/QuizScreens/Question7.dart b/lib/QuizScreens/Question7.dart index edcbf6e..2f47dbf 100644 --- a/lib/QuizScreens/Question7.dart +++ b/lib/QuizScreens/Question7.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:test_app/model/QuizDataModel.dart'; -import 'package:test_app/QuizScreens/Question8.dart'; +import 'package:book_rent_app_chapter3/model/QuizDataModel.dart'; +import 'package:book_rent_app_chapter3/QuizScreens/Question8.dart'; //ignore: must_be_immutable class Question7 extends StatefulWidget { QuizData quizData = QuizData(); - Question7({this.quizData}); + Question7({required this.quizData}); @override _Question7State createState() => _Question7State(); @@ -17,7 +17,7 @@ class Question7 extends StatefulWidget { } class _Question7State extends State { - String chosen; + String? chosen; bool answered = false; String option1 = 'I love when books make my heart\nbeat faster'; String option2 = 'I love when the book keeps me\nguessing'; diff --git a/lib/QuizScreens/Question8.dart b/lib/QuizScreens/Question8.dart index 975c1fd..36d15ed 100644 --- a/lib/QuizScreens/Question8.dart +++ b/lib/QuizScreens/Question8.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:test_app/QuizScreens/Question9.dart'; -import 'package:test_app/model/QuizDataModel.dart'; +import 'package:book_rent_app_chapter3/QuizScreens/Question9.dart'; +import 'package:book_rent_app_chapter3/model/QuizDataModel.dart'; //ignore: must_be_immutable class Question8 extends StatefulWidget { QuizData quizData = QuizData(); - Question8({this.quizData}); + Question8({required this.quizData}); @override _Question8State createState() => _Question8State(); @@ -19,7 +19,7 @@ class Question8 extends StatefulWidget { } class _Question8State extends State { - String chosen; + String? chosen; bool answered = false; String option1 = 'I wanna be happy and filled with\npositivity'; String option2 = 'Tear jerker, Hit me with a solid\nemotional story'; diff --git a/lib/QuizScreens/Question9.dart b/lib/QuizScreens/Question9.dart index dd9c57b..62fb219 100644 --- a/lib/QuizScreens/Question9.dart +++ b/lib/QuizScreens/Question9.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:test_app/QuizScreens/QuizResult.dart'; -import 'package:test_app/model/QuizDataModel.dart'; +import 'package:book_rent_app_chapter3/QuizScreens/QuizResult.dart'; +import 'package:book_rent_app_chapter3/model/QuizDataModel.dart'; //ignore: must_be_immutable class Question9 extends StatefulWidget { QuizData quizData = QuizData(); - Question9({this.quizData}); + Question9({required this.quizData}); @override _Question9State createState() => _Question9State(); @@ -19,7 +19,7 @@ class Question9 extends StatefulWidget { } class _Question9State extends State { - String chosen; + String? chosen; bool answered = false; String option1 = 'The boldness of asking deep\nquestions may require unforeseen\nflexibility if we are to\naccept the answers.'; diff --git a/lib/QuizScreens/QuizResult.dart b/lib/QuizScreens/QuizResult.dart index 272b8ed..cd5139e 100644 --- a/lib/QuizScreens/QuizResult.dart +++ b/lib/QuizScreens/QuizResult.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:test_app/model/QuizDataModel.dart'; +import 'package:book_rent_app_chapter3/model/QuizDataModel.dart'; import 'package:quiver/iterables.dart' as quiver; //ignore: must_be_immutable class QuizResult extends StatefulWidget { final QuizData quizData; - const QuizResult({Key key, this.quizData}) : super(key: key); + const QuizResult({Key? key, required this.quizData}) : super(key: key); @override _QuizResultState createState() => _QuizResultState(); @@ -29,7 +29,7 @@ class _QuizResultState extends State { widget.quizData.ts, widget.quizData.kr ]; - int maxBook = quiver.max(books); + int maxBook = quiver.max(books)!; if (maxBook == 0) { bookSuggestion = 'Please attempt the quiz first'; diff --git a/lib/Screens/AboutUs.dart b/lib/Screens/AboutUs.dart index 7521e65..8b3e390 100644 --- a/lib/Screens/AboutUs.dart +++ b/lib/Screens/AboutUs.dart @@ -96,22 +96,22 @@ class _AboutUsState extends State { margin: const EdgeInsets.only(left: 15, right: 15), child: Column( children: [ - _buildProfileImage(devTeam[index]["imgPath"]), + _buildProfileImage(devTeam[index]["imgPath"]!), Container( margin: const EdgeInsets.only(top: 10), child: Column( children: [ Text( - devTeam[index]["name"], + devTeam[index]["name"]!, ), const Padding(padding: EdgeInsets.only(top: 5)), Row( children: [ - _buildProfileIcon(devTeam[index]["linkedin"], + _buildProfileIcon(devTeam[index]["linkedin"]!, 'https://img.icons8.com/fluent/48/000000/linkedin-circled.png'), const Padding( padding: EdgeInsets.only(left: 10)), - _buildProfileIcon(devTeam[index]["github"], + _buildProfileIcon(devTeam[index]["github"]!, 'https://img.icons8.com/fluent/50/000000/github.png'), ], ) diff --git a/lib/Screens/AdminSignIn.dart b/lib/Screens/AdminSignIn.dart index 08eda29..a009937 100644 --- a/lib/Screens/AdminSignIn.dart +++ b/lib/Screens/AdminSignIn.dart @@ -1,7 +1,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; -import 'package:test_app/Screens/AdminPage.dart'; -import 'package:test_app/Screens/LoginPage.dart'; +import 'package:book_rent_app_chapter3/Screens/AdminPage.dart'; +import 'package:book_rent_app_chapter3/Screens/LoginPage.dart'; class AdminSignIn extends StatefulWidget { @override @@ -32,7 +32,7 @@ class _AdminSignInState extends State { TextFormField( controller: _emailTextController, decoration: InputDecoration(hintText: 'email'), - validator: (val) => val.isEmpty ? 'Enter an email' : null, + validator: (val) => val!.isEmpty ? 'Enter an email' : null, textAlignVertical: TextAlignVertical.bottom, ), SizedBox( @@ -42,7 +42,7 @@ class _AdminSignInState extends State { controller: _passwordTextController, decoration: InputDecoration(hintText: 'password'), validator: (val) => - val.length < 6 ? 'Enter a password 6+ chars long' : null, + val!.length < 6 ? 'Enter a password 6+ chars long' : null, textAlignVertical: TextAlignVertical.bottom, obscureText: true, ), @@ -51,7 +51,7 @@ class _AdminSignInState extends State { ), ElevatedButton( onPressed: () async { - if (_formKey.currentState.validate()) { + if (_formKey.currentState!.validate()) { loginAdmin(); } }, diff --git a/lib/Screens/AllBooks.dart b/lib/Screens/AllBooks.dart index 567e534..f0e448c 100644 --- a/lib/Screens/AllBooks.dart +++ b/lib/Screens/AllBooks.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:test_app/Widgets.dart'; +import 'package:book_rent_app_chapter3/Widgets.dart'; class AllBooks extends StatefulWidget { @override diff --git a/lib/Screens/BestSellers.dart b/lib/Screens/BestSellers.dart index 9643652..822b687 100644 --- a/lib/Screens/BestSellers.dart +++ b/lib/Screens/BestSellers.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/provider/product.dart'; -import 'package:test_app/Widgets.dart'; +import 'package:book_rent_app_chapter3/provider/product.dart'; +import 'package:book_rent_app_chapter3/Widgets.dart'; class BestSellers extends StatefulWidget { @override diff --git a/lib/Screens/Contact.dart b/lib/Screens/Contact.dart index c82a663..cf7ca1d 100644 --- a/lib/Screens/Contact.dart +++ b/lib/Screens/Contact.dart @@ -58,7 +58,7 @@ class _ContactUsState extends State { ), ClickableCard( textContent: 'Suggest some feature', - color: Colors.purple[300], + color: Colors.purple[300]!, onTap: () async { await _launchURL( 'https://github.com/Saransh-cpp/BookRentApp-Chapter3/issues'); @@ -81,7 +81,7 @@ class _ContactUsState extends State { ), ClickableCard( textContent: 'Rate us on PlayStore', - color: Colors.red[300], + color: Colors.red[300]!, onTap: () async { await _launchURL('apps_playStore_link_here'); }, @@ -113,9 +113,9 @@ class _ContactUsState extends State { class ClickableCard extends StatelessWidget { ClickableCard( - {@required this.textContent, @required this.onTap, @required this.color}); + {required this.textContent, required this.onTap, required this.color}); final String textContent; - final Function onTap; + final Function() onTap; final Color color; @override diff --git a/lib/Screens/Favourites.dart b/lib/Screens/Favourites.dart index 04272f1..55bf2b0 100644 --- a/lib/Screens/Favourites.dart +++ b/lib/Screens/Favourites.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/Screens/Loading.dart'; -import 'package:test_app/provider/app.dart'; -import 'package:test_app/provider/user.dart'; +import 'package:book_rent_app_chapter3/Screens/Loading.dart'; +import 'package:book_rent_app_chapter3/provider/app.dart'; +import 'package:book_rent_app_chapter3/provider/user.dart'; class Favourites extends StatefulWidget { @override @@ -33,7 +33,7 @@ class _FavouritesState extends State { body: appProvider.isLoading ? Loading() : ListView.builder( - itemCount: userProvider.userModel.fav.length, + itemCount: userProvider.userModel.fav!.length, itemBuilder: (_, index) { return Padding( padding: const EdgeInsets.all(16), @@ -58,7 +58,7 @@ class _FavouritesState extends State { topLeft: Radius.circular(20), ), child: Image.network( - userProvider.userModel.fav[index].image, + userProvider.userModel.fav![index].image, height: 120, width: 140, fit: BoxFit.fill, @@ -76,7 +76,7 @@ class _FavouritesState extends State { text: TextSpan(children: [ TextSpan( text: userProvider - .userModel.fav[index].name + + .userModel.fav![index].name + "\n", style: TextStyle( color: Colors.black, @@ -84,7 +84,7 @@ class _FavouritesState extends State { fontWeight: FontWeight.bold)), TextSpan( text: - "\$${userProvider.userModel.fav[index].price} \n\n", + "\$${userProvider.userModel.fav![index].price} \n\n", style: TextStyle( color: Colors.black, fontSize: 18, @@ -101,7 +101,7 @@ class _FavouritesState extends State { bool success = await userProvider.removeFromFav( favItem: userProvider - .userModel.fav[index]); + .userModel.fav![index]); if (success) { userProvider.reloadUserModel(); ScaffoldMessenger.of(context).showSnackBar( diff --git a/lib/Screens/Home.dart b/lib/Screens/Home.dart index c4c6d45..1f3b8ff 100644 --- a/lib/Screens/Home.dart +++ b/lib/Screens/Home.dart @@ -1,23 +1,23 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/QuizScreens/Question1.dart'; -//import 'package:test_app/Screens/LoginPage.dart'; -import 'package:test_app/Screens/orders.dart'; -import 'package:test_app/Screens/product_search.dart'; -import 'package:test_app/Widgets.dart'; -//import 'package:test_app/database.dart'; -//import 'package:test_app/Screens/Register.dart'; -import 'package:test_app/provider/product.dart'; -import 'package:test_app/provider/user.dart'; -//import 'package:test_app/services/product.dart'; -import 'package:test_app/Screens/Favourites.dart'; -import 'package:test_app/Screens/Profile.dart'; -//import 'package:test_app/Screens/Quiz.dart'; -import 'package:test_app/Screens/Recommendations.dart'; -import 'package:test_app/Screens/BestSellers.dart'; -import 'package:test_app/Screens/AboutUs.dart'; -import 'package:test_app/Screens/Contact.dart'; -import 'package:test_app/Screens/Report.dart'; +import 'package:book_rent_app_chapter3/QuizScreens/Question1.dart'; +//import 'package:book_rent_app_chapter3/Screens/LoginPage.dart'; +import 'package:book_rent_app_chapter3/Screens/orders.dart'; +import 'package:book_rent_app_chapter3/Screens/product_search.dart'; +import 'package:book_rent_app_chapter3/Widgets.dart'; +//import 'package:book_rent_app_chapter3/database.dart'; +//import 'package:book_rent_app_chapter3/Screens/Register.dart'; +import 'package:book_rent_app_chapter3/provider/product.dart'; +import 'package:book_rent_app_chapter3/provider/user.dart'; +//import 'package:book_rent_app_chapter3/services/product.dart'; +import 'package:book_rent_app_chapter3/Screens/Favourites.dart'; +import 'package:book_rent_app_chapter3/Screens/Profile.dart'; +//import 'package:book_rent_app_chapter3/Screens/Quiz.dart'; +import 'package:book_rent_app_chapter3/Screens/Recommendations.dart'; +import 'package:book_rent_app_chapter3/Screens/BestSellers.dart'; +import 'package:book_rent_app_chapter3/Screens/AboutUs.dart'; +import 'package:book_rent_app_chapter3/Screens/Contact.dart'; +import 'package:book_rent_app_chapter3/Screens/Report.dart'; class Home extends StatefulWidget { @override @@ -137,7 +137,7 @@ class _HomeState extends State { color: Colors.black, ), onPressed: () { - _drawerKey.currentState.openDrawer(); + _drawerKey.currentState!.openDrawer(); }, ), backgroundColor: Colors.white, @@ -204,10 +204,10 @@ class _HomeState extends State { child: Container( decoration: BoxDecoration( border: Border.all( - color: Colors.pink[50], + color: Colors.pink[50]!, ), borderRadius: - BorderRadius.all(Radius.circular(50)), + BorderRadius.all(Radius.circular(50)!), color: Colors.pink[200]), height: MediaQuery.of(context).size.height * 0.7, width: MediaQuery.of(context).size.width * 0.97, @@ -222,7 +222,7 @@ class _HomeState extends State { Container( decoration: BoxDecoration( border: Border.all( - color: Colors.pink[900], + color: Colors.pink[900]!, ), borderRadius: BorderRadius.all( Radius.circular(50)), @@ -264,7 +264,7 @@ class _HomeState extends State { decoration: BoxDecoration( color: Colors.white, border: Border.all( - color: Colors.pink[900], + color: Colors.pink[900]!, ), borderRadius: BorderRadius.all( Radius.circular(20))), @@ -290,7 +290,7 @@ class _HomeState extends State { decoration: BoxDecoration( color: Colors.white, border: Border.all( - color: Colors.pink[900], + color: Colors.pink[900]!, ), borderRadius: BorderRadius.all( Radius.circular(20))), @@ -317,7 +317,7 @@ class _HomeState extends State { decoration: BoxDecoration( color: Colors.white, border: Border.all( - color: Colors.pink[900], + color: Colors.pink[900]!, ), borderRadius: BorderRadius.all( Radius.circular(20))), diff --git a/lib/Screens/Loading.dart b/lib/Screens/Loading.dart index 0972dd5..6cebdf2 100644 --- a/lib/Screens/Loading.dart +++ b/lib/Screens/Loading.dart @@ -15,7 +15,7 @@ class _LoadingState extends State { home: SafeArea( child: Container( child: Center( - child: SpinKitPouringHourglass( + child: SpinKitRotatingCircle( size: 50, color: Colors.brown, )), diff --git a/lib/Screens/LoginPage.dart b/lib/Screens/LoginPage.dart index 03331be..b9ee069 100644 --- a/lib/Screens/LoginPage.dart +++ b/lib/Screens/LoginPage.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/Screens/Loading.dart'; -import 'package:test_app/Screens/Register.dart'; +import 'package:book_rent_app_chapter3/Screens/Loading.dart'; +import 'package:book_rent_app_chapter3/Screens/Register.dart'; -import 'package:test_app/provider/user.dart'; +import 'package:book_rent_app_chapter3/provider/user.dart'; class LoginPage extends StatefulWidget { @override @@ -32,7 +32,7 @@ class _LoginPageState extends State { class SignIn extends StatefulWidget { final Function toggleView; - SignIn({this.toggleView}); + SignIn({required this.toggleView}); @override _SignInState createState() => _SignInState(); } @@ -80,7 +80,7 @@ class _SignInState extends State { controller: _emailTextController, decoration: InputDecoration(hintText: 'email'), validator: (val) => - val.isEmpty ? 'Enter an email' : null, + val!.isEmpty ? 'Enter an email' : null, textAlignVertical: TextAlignVertical.bottom, onChanged: (val) { setState(() { @@ -94,7 +94,7 @@ class _SignInState extends State { TextFormField( controller: _passwordTextController, decoration: InputDecoration(hintText: 'password'), - validator: (val) => val.length < 6 + validator: (val) => val!.length < 6 ? 'Enter a password 6+ chars long' : null, textAlignVertical: TextAlignVertical.bottom, @@ -110,11 +110,11 @@ class _SignInState extends State { ), ElevatedButton( onPressed: () async { - if (_formKey.currentState.validate()) { + if (_formKey.currentState!.validate()) { if (!await user.signIn( _emailTextController.text, _passwordTextController.text)) { - ScaffoldMessenger.of(context).showSnackBar(SnackBar( + ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text("Sign in failed"))); } } @@ -146,4 +146,4 @@ class _SignInState extends State { )), ); } -} +} \ No newline at end of file diff --git a/lib/Screens/NavBar.dart b/lib/Screens/NavBar.dart index ae4e636..c358b76 100644 --- a/lib/Screens/NavBar.dart +++ b/lib/Screens/NavBar.dart @@ -1,8 +1,8 @@ import 'package:curved_navigation_bar/curved_navigation_bar.dart'; import 'package:flutter/material.dart'; -import 'package:test_app/Screens/YourOrders.dart'; -import 'package:test_app/Screens/AllBooks.dart'; -import 'package:test_app/Screens/Home.dart'; +import 'package:book_rent_app_chapter3/Screens/YourOrders.dart'; +import 'package:book_rent_app_chapter3/Screens/AllBooks.dart'; +import 'package:book_rent_app_chapter3/Screens/Home.dart'; class NavBar extends StatefulWidget { @override @@ -34,7 +34,7 @@ class _NavBarState extends State { ), bottomNavigationBar: CurvedNavigationBar( height: 60.0, - backgroundColor: Colors.pink[50], + backgroundColor: Colors.pink[50]!, items: [ Icon(Icons.home_rounded, size: 30), Icon(Icons.menu_book_rounded, size: 30), diff --git a/lib/Screens/Profile.dart b/lib/Screens/Profile.dart index 2067613..4c751d4 100644 --- a/lib/Screens/Profile.dart +++ b/lib/Screens/Profile.dart @@ -1,10 +1,10 @@ import 'package:provider/provider.dart'; -import 'package:test_app/Screens/Loading.dart'; +import 'package:book_rent_app_chapter3/Screens/Loading.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; -import 'package:test_app/provider/user.dart'; +import 'package:book_rent_app_chapter3/provider/user.dart'; class UpdateProfile extends StatefulWidget { @override @@ -89,7 +89,7 @@ class _UpdateProfileState extends State { decoration: InputDecoration( prefixIcon: Icon(Icons.person)), validator: (val) => - val.isEmpty ? 'Enter a name' : null, + val!.isEmpty ? 'Enter a name' : null, textAlignVertical: TextAlignVertical.bottom, ), ), @@ -116,7 +116,7 @@ class _UpdateProfileState extends State { }); }, validator: (val) => - val.isEmpty ? 'Enter an email' : null, + val!.isEmpty ? 'Enter an email' : null, textAlignVertical: TextAlignVertical.bottom, ), ), @@ -144,7 +144,7 @@ class _UpdateProfileState extends State { prefixIcon: Icon(Icons.home_work_rounded)), validator: (val) => - val.isEmpty ? 'Enter an address' : null, + val!.isEmpty ? 'Enter an address' : null, textAlignVertical: TextAlignVertical.bottom, ), ), @@ -171,7 +171,7 @@ class _UpdateProfileState extends State { hintText: "Enter bio", prefixIcon: Icon(Icons.email)), validator: (val) => - val.isEmpty ? 'Enter a bio' : null, + val!.isEmpty ? 'Enter a bio' : null, textAlignVertical: TextAlignVertical.bottom, ), ), @@ -199,7 +199,7 @@ class _UpdateProfileState extends State { hintText: "Enter number", prefixIcon: Icon(Icons.phone)), validator: (val) => - val.isEmpty ? 'Enter a number' : null, + val!.isEmpty ? 'Enter a number' : null, textAlignVertical: TextAlignVertical.bottom, ), ), @@ -208,7 +208,7 @@ class _UpdateProfileState extends State { ), ElevatedButton( onPressed: () async { - if (_formKey.currentState.validate()) { + if (_formKey.currentState!.validate()) { setState(() { isLoading = true; }); @@ -228,7 +228,7 @@ class _UpdateProfileState extends State { setState(() { isLoading = false; }); - _key.currentState.showSnackBar(SnackBar( + _key.currentState!.showSnackBar(SnackBar( content: Text( "Network Issue, Try again"))); } else { diff --git a/lib/Screens/Recommendations.dart b/lib/Screens/Recommendations.dart index 53b271b..21ac125 100644 --- a/lib/Screens/Recommendations.dart +++ b/lib/Screens/Recommendations.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/provider/product.dart'; -import 'package:test_app/Widgets.dart'; +import 'package:book_rent_app_chapter3/provider/product.dart'; +import 'package:book_rent_app_chapter3/Widgets.dart'; class Recommendations extends StatefulWidget { @override diff --git a/lib/Screens/Register.dart b/lib/Screens/Register.dart index 77fc3d0..3dc0550 100644 --- a/lib/Screens/Register.dart +++ b/lib/Screens/Register.dart @@ -1,21 +1,21 @@ import 'package:provider/provider.dart'; -import 'package:test_app/Screens/Loading.dart'; +import 'package:book_rent_app_chapter3/Screens/Loading.dart'; //import 'package:fluttertoast/fluttertoast.dart'; -//import 'package:test_app/Utility/auth.dart'; -//import 'package:test_app/main.dart'; +//import 'package:book_rent_app_chapter3/Utility/auth.dart'; +//import 'package:book_rent_app_chapter3/main.dart'; //import 'dart:io'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; //import 'package:image_picker/image_picker.dart'; //import 'package:shared_preferences/shared_preferences.dart'; -//import 'package:test_app/Screens/LoginPage.dart'; +//import 'package:book_rent_app_chapter3/Screens/LoginPage.dart'; //import 'package:firebase_storage/firebase_storage.dart'; -import 'package:test_app/provider/user.dart'; +import 'package:book_rent_app_chapter3/provider/user.dart'; class Register extends StatefulWidget { final Function toggleView; - Register({this.toggleView}); + Register({required this.toggleView}); @override _RegisterState createState() => _RegisterState(); } @@ -57,7 +57,7 @@ class _RegisterState extends State { ? _nameTextController : _emailTextController, decoration: InputDecoration(hintText: "$hint", prefixIcon: icon), - validator: (val) => val.isEmpty ? '$error' : null, + validator: (val) => val!.isEmpty ? '$error' : null, textAlignVertical: TextAlignVertical.bottom, onChanged: (val) { if ("$hint" == "Enter Email") { @@ -113,7 +113,7 @@ class _RegisterState extends State { }); }), ), - validator: (val) => val.length < 6 ? '$error' : null, + validator: (val) => val!.length < 6 ? '$error' : null, textAlignVertical: TextAlignVertical.bottom, obscureText: hidePass1, onChanged: (val) { @@ -156,7 +156,7 @@ class _RegisterState extends State { }); }), ), - validator: (val) => passwordValidator(val), + validator: (val) => passwordValidator(val!), textAlignVertical: TextAlignVertical.bottom, obscureText: hidePass2, ), @@ -211,7 +211,7 @@ class _RegisterState extends State { 'Enter a password 6+ chars long'), ElevatedButton( onPressed: () async { - if (_formKey.currentState + if (_formKey.currentState! .validate()) { if (!await user.signUp( _nameTextController.text, @@ -261,7 +261,7 @@ class UserServices { FirebaseFirestore _firestore = FirebaseFirestore.instance; String collection = "users"; - void createUser(Map data) { + void createUser(Map data) { _firestore.collection(collection).doc(data["userId"]).set(data); } -} +} \ No newline at end of file diff --git a/lib/Screens/YourOrders.dart b/lib/Screens/YourOrders.dart index bafa176..bd69467 100644 --- a/lib/Screens/YourOrders.dart +++ b/lib/Screens/YourOrders.dart @@ -1,13 +1,12 @@ -import 'package:firebase_admob/firebase_admob.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/Screens/Loading.dart'; -import 'package:test_app/Screens/Recommendations.dart'; -import 'package:test_app/Screens/product_details.dart'; -import 'package:test_app/model/cart_item.dart'; -import 'package:test_app/provider/app.dart'; -import 'package:test_app/provider/user.dart'; -import 'package:test_app/services/order.dart'; +import 'package:book_rent_app_chapter3/Screens/Loading.dart'; +import 'package:book_rent_app_chapter3/Screens/Recommendations.dart'; +import 'package:book_rent_app_chapter3/Screens/product_details.dart'; +import 'package:book_rent_app_chapter3/model/cart_item.dart'; +import 'package:book_rent_app_chapter3/provider/app.dart'; +import 'package:book_rent_app_chapter3/provider/user.dart'; +import 'package:book_rent_app_chapter3/services/order.dart'; import 'package:uuid/uuid.dart'; // const String testDevice = 'ca-app-pub-2019702807519064~1210594994'; @@ -18,42 +17,17 @@ class YourOrders extends StatefulWidget { } class _YourOrdersState extends State { - static MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo( - testDevices: [], - contentUrl: 'https://flutter.io', - childDirected: true, - keywords: ['books', 'library', 'novels'], - ); OrderServices _orderServices = OrderServices(); ProductDetails productDetails = ProductDetails(); - BannerAd _bannerAd; - BuildContext _scaffoldContext; - - BannerAd createBannerAd() { - return BannerAd( - adUnitId: 'ca-app-pub-2019702807519064/7611340051', - size: AdSize.banner, - targetingInfo: targetingInfo, - listener: (MobileAdEvent event) { - print('Banner event : $event'); - }); - } @override void initState() { super.initState(); - FirebaseAdMob.instance - .initialize(appId: 'ca-app-pub-2019702807519064~1210594994'); - // showBannerAd(); - _bannerAd = createBannerAd() - ..load() - ..show(anchorOffset: 125); } @override void dispose() { - _bannerAd.dispose(); super.dispose(); } @@ -61,353 +35,352 @@ class _YourOrdersState extends State { Widget build(BuildContext context) { final userProvider = Provider.of(context); final appProvider = Provider.of(context); - bool isCartEmpty = userProvider.userModel.cart.length == 0; - _scaffoldContext = context; + bool isCartEmpty = userProvider.userModel.cart!.isEmpty; + BuildContext _scaffoldContext = context; return MaterialApp( debugShowCheckedModeBanner: false, home: SafeArea( child: Scaffold( - appBar: AppBar( - iconTheme: IconThemeData( - color: Colors.pink, - ), - backgroundColor: Colors.pink[50], - elevation: 0, - title: Text( - "My Cart", - style: TextStyle(color: Colors.black, fontSize: 20), - ), - ), - backgroundColor: Colors.pink[50], - body: appProvider.isLoading - ? Loading() - : isCartEmpty + appBar: AppBar( + iconTheme: IconThemeData( + color: Colors.pink, + ), + backgroundColor: Colors.pink[50], + elevation: 0, + title: Text( + "My Cart", + style: TextStyle(color: Colors.black, fontSize: 20), + ), + ), + backgroundColor: Colors.pink[50], + body: appProvider.isLoading + ? Loading() + : isCartEmpty ? Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - 'images/emptycart.png', - ), - Padding( - padding: const EdgeInsets.symmetric( - vertical: 8, horizontal: 20), - child: Card( - elevation: 3, - shadowColor: Colors.grey, - child: Padding( - padding: EdgeInsets.all(30), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - children: [ - TextSpan( - text: - 'You have nothing in your cart ,click on ', - style: TextStyle( - fontSize: 20, - color: Colors.pinkAccent), - ), - TextSpan( - text: 'add item', - style: TextStyle( - fontSize: 20, - color: Colors.teal, - fontWeight: FontWeight.bold), - ), - TextSpan( - text: ' to find your recommendation.', - style: TextStyle( - fontSize: 20, - color: Colors.pinkAccent), - ) - ], - ), + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + 'images/emptycart.png', + ), + Padding( + padding: const EdgeInsets.symmetric( + vertical: 8, horizontal: 20), + child: Card( + elevation: 3, + shadowColor: Colors.grey, + child: Padding( + padding: EdgeInsets.all(30), + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + children: [ + TextSpan( + text: + 'You have nothing in your cart ,click on ', + style: TextStyle( + fontSize: 20, + color: Colors.pinkAccent), ), - ), + TextSpan( + text: 'add item', + style: TextStyle( + fontSize: 20, + color: Colors.teal, + fontWeight: FontWeight.bold), + ), + TextSpan( + text: ' to find your recommendation.', + style: TextStyle( + fontSize: 20, + color: Colors.pinkAccent), + ) + ], ), ), - ], - ) + ), + ), + ), + ], + ) : ListView.builder( - itemCount: userProvider.userModel.cart.length, - itemBuilder: (_, index) { - return Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16, vertical: 8), - child: Container( - height: 120, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Colors.grey, - offset: Offset(3, 2), - blurRadius: 30) - ]), - child: InkWell( - onTap: () { - // Navigator.push(context, MaterialPageRoute( - // builder: (c) => ProductDetails - // (product: product))); - }, + itemCount: userProvider.userModel.cart!.length, + itemBuilder: (_, index) { + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, vertical: 8), + child: Container( + height: 120, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.grey, + offset: Offset(3, 2), + blurRadius: 30) + ]), + child: InkWell( + onTap: () { + // Navigator.push(context, MaterialPageRoute( + // builder: (c) => ProductDetails + // (product: product))); + }, + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(10), + topLeft: Radius.circular(10), + ), + child: Image.network( + userProvider.userModel.cart![index].image, + height: 120, + width: 140, + fit: BoxFit.fill, + ), + ), + SizedBox( + width: 10, + ), + Expanded( child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - ClipRRect( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(10), - topLeft: Radius.circular(10), - ), - child: Image.network( - userProvider.userModel.cart[index].image, - height: 120, - width: 140, - fit: BoxFit.fill, - ), - ), - SizedBox( - width: 10, + RichText( + text: TextSpan(children: [ + TextSpan( + text: userProvider.userModel + .cart![index].name + + "\n", + style: TextStyle( + color: Colors.black, + fontSize: 20, + fontWeight: + FontWeight.bold)), + TextSpan( + // text: userProvider.userModel + // .cart[index].size == '1 week' + // ? userProvider.userModel + // .cart[index].price[0] + // : userProvider.userModel + // .cart[index].price[1], + text: + "\$${userProvider.userModel.cart![index].price} \n\n", + style: TextStyle( + color: Colors.black, + fontSize: 18, + fontWeight: + FontWeight.w300)), + ]), ), - Expanded( - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - RichText( - text: TextSpan(children: [ - TextSpan( - text: userProvider.userModel - .cart[index].name + - "\n", - style: TextStyle( - color: Colors.black, - fontSize: 20, - fontWeight: - FontWeight.bold)), - TextSpan( - // text: userProvider.userModel - // .cart[index].size == '1 week' - // ? userProvider.userModel - // .cart[index].price[0] - // : userProvider.userModel - // .cart[index].price[1], - text: - "\$${userProvider.userModel.cart[index].price} \n\n", - style: TextStyle( - color: Colors.black, - fontSize: 18, - fontWeight: - FontWeight.w300)), - ]), - ), - IconButton( - icon: Icon( - Icons.delete, - color: Colors.red, - ), - onPressed: () async { + IconButton( + icon: Icon( + Icons.delete, + color: Colors.red, + ), + onPressed: () async { + appProvider.changeIsLoading(); + bool success = + await userProvider.removeFromCart( + cartItem: userProvider + .userModel.cart![index]); + if (success) { + userProvider.reloadUserModel(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + "Removed from Cart!"))); + appProvider.changeIsLoading(); + return; + } else { appProvider.changeIsLoading(); - bool success = - await userProvider.removeFromCart( - cartItem: userProvider - .userModel.cart[index]); - if (success) { - userProvider.reloadUserModel(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - "Removed from Cart!"))); - appProvider.changeIsLoading(); - return; - } else { - appProvider.changeIsLoading(); - } - }) - ], - ), - ) + } + }) ], ), - ), - ), - ); - }, + ) + ], + ), + ), ), - bottomNavigationBar: Container( - child: Padding( - padding: + ); + }, + ), + bottomNavigationBar: Container( + child: Padding( + padding: const EdgeInsets.only(left: 8, top: 0, right: 8, bottom: 16), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - RichText( - text: TextSpan(children: [ - TextSpan( - text: "Total: ", - style: TextStyle( - color: Colors.grey, - fontSize: 22, - fontWeight: FontWeight.w400)), - TextSpan( - text: " \$${userProvider.userModel.totalCartPrice}", - style: TextStyle( - color: Colors.black, - fontSize: 22, - fontWeight: FontWeight.normal)), - ]), - ), - Card( - color: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(100), - ), - elevation: 3, - shadowColor: Colors.grey, - child: TextButton( - onPressed: () { - if (userProvider.userModel.totalCartPrice == 0) { - _bannerAd.dispose(); - Navigator.push( - context, - MaterialPageRoute( - builder: (c) => Recommendations())); - return; - } - showDialog( - context: context, - builder: (BuildContext context) { - return Dialog( - shape: RoundedRectangleBorder( - borderRadius: + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + RichText( + text: TextSpan(children: [ + TextSpan( + text: "Total: ", + style: TextStyle( + color: Colors.grey, + fontSize: 22, + fontWeight: FontWeight.w400)), + TextSpan( + text: " \$${userProvider.userModel.totalCartPrice}", + style: TextStyle( + color: Colors.black, + fontSize: 22, + fontWeight: FontWeight.normal)), + ]), + ), + Card( + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(100), + ), + elevation: 3, + shadowColor: Colors.grey, + child: TextButton( + onPressed: () { + if (userProvider.userModel.totalCartPrice == 0) { + Navigator.push( + context, + MaterialPageRoute( + builder: (c) => Recommendations())); + return; + } + showDialog( + context: context, + builder: (BuildContext context) { + return Dialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20.0)), - child: Container( - height: 200, - child: Padding( - padding: const EdgeInsets.all(12.0), - child: Column( - mainAxisAlignment: + child: Container( + height: 200, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: + crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'You will be charged \$${userProvider.userModel.totalCartPrice} upon delivery!', - textAlign: TextAlign.center, - ), - SizedBox( - width: 320.0, - child: ElevatedButton( - onPressed: () async { - var uuid = Uuid(); - String id = uuid.v4(); - if (userProvider.userModel - .address != + children: [ + Text( + 'You will be charged \$${userProvider.userModel.totalCartPrice} upon delivery!', + textAlign: TextAlign.center, + ), + SizedBox( + width: 320.0, + child: ElevatedButton( + onPressed: () async { + var uuid = Uuid(); + String id = uuid.v4(); + if (userProvider.userModel + .address != '' && - userProvider + userProvider .userModel.number != - '') { - String orderNames = - '${userProvider.userModel.cart[0].name}'; - for (int i = 1; + '') { + String orderNames = + '${userProvider.userModel.cart![0].name}'; + for (int i = 1; i < userProvider.userModel - .cart.length; + .cart!.length; i++) { - orderNames = orderNames + - ', ${userProvider.userModel.cart[i].name}'; - } - _orderServices.createOrder( - userId: + orderNames = orderNames + + ', ${userProvider.userModel.cart![i].name}'; + } + _orderServices.createOrder( + userId: userProvider.user.uid, - id: id, - description: orderNames, - status: "ordered", - totalPrice: userProvider - .userModel - .totalCartPrice, - cart: userProvider - .userModel.cart); - for (CartItemModel cartItem + id: id, + description: orderNames, + status: "ordered", + totalPrice: userProvider + .userModel + .totalCartPrice!, + cart: userProvider + .userModel.cart!); + for (CartItemModel cartItem in userProvider - .userModel.cart) { - bool value = + .userModel.cart!) { + bool value = await userProvider .removeFromCart( - cartItem: - cartItem); - if (value) { - userProvider - .reloadUserModel(); - print( - "Item added to cart"); - } else { - print( - "ITEM WAS NOT REMOVED"); - } - } - Navigator.pop(context); - ScaffoldMessenger.of(_scaffoldContext) - .showSnackBar(SnackBar( + cartItem: + cartItem); + if (value) { + userProvider + .reloadUserModel(); + print( + "Item added to cart"); + } else { + print( + "ITEM WAS NOT REMOVED"); + } + } + Navigator.pop(context); + ScaffoldMessenger.of(_scaffoldContext) + .showSnackBar(SnackBar( content: Text( "Order created!"))); - } else { - Navigator.pop(context); - ScaffoldMessenger.of(_scaffoldContext) - .showSnackBar(SnackBar( + } else { + Navigator.pop(context); + ScaffoldMessenger.of(_scaffoldContext) + .showSnackBar(SnackBar( content: Text( 'Please add address and number'))); - } - }, - child: Text( - "Accept", - style: TextStyle( - color: Colors.white), - ), - style: ElevatedButton.styleFrom( - primary: + } + }, + child: Text( + "Accept", + style: TextStyle( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + primary: const Color(0xFF1BC0C5)), - ), - ), - SizedBox( - width: 320.0, - child: ElevatedButton( - onPressed: () { - Navigator.pop(context); - }, - child: Text( - "Reject", - style: TextStyle( - color: Colors.white), + ), ), - style: ElevatedButton.styleFrom( - primary: Colors.red), - ), - ) - ], + SizedBox( + width: 320.0, + child: ElevatedButton( + onPressed: () { + Navigator.pop(context); + }, + child: Text( + "Reject", + style: TextStyle( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + primary: Colors.red), + ), + ) + ], + ), + ), ), - ), - ), - ); - }); - }, - child: Padding( - padding: EdgeInsets.only( - left: 10.0, top: 5.0, right: 10.0, bottom: 0.0), - child: Text( - isCartEmpty ? 'Add Item' : 'Check Out', - style: TextStyle( - color: Colors.teal, - fontSize: 18, - ), - ), - )), - ) - ], + ); + }); + }, + child: Padding( + padding: EdgeInsets.only( + left: 10.0, top: 5.0, right: 10.0, bottom: 0.0), + child: Text( + isCartEmpty ? 'Add Item' : 'Check Out', + style: TextStyle( + color: Colors.teal, + fontSize: 18, + ), + ), + )), + ) + ], + ), + ), ), - ), - ), - ))); + ))); } -} +} \ No newline at end of file diff --git a/lib/Screens/allBooksofAGenre.dart b/lib/Screens/allBooksofAGenre.dart index 6cc1262..418227f 100644 --- a/lib/Screens/allBooksofAGenre.dart +++ b/lib/Screens/allBooksofAGenre.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/provider/product.dart'; -import 'package:test_app/Widgets.dart'; +import 'package:book_rent_app_chapter3/provider/product.dart'; +import 'package:book_rent_app_chapter3/Widgets.dart'; class AllBooksofAGenre extends StatefulWidget { final String genre; - const AllBooksofAGenre({Key key, this.genre}) : super(key: key); + const AllBooksofAGenre({Key? key,required this.genre}) : super(key: key); @override _AllBooksofAGenreState createState() => _AllBooksofAGenreState(); diff --git a/lib/Screens/orders.dart b/lib/Screens/orders.dart index 041241c..9b2057b 100644 --- a/lib/Screens/orders.dart +++ b/lib/Screens/orders.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/model/order.dart'; -import 'package:test_app/provider/user.dart'; +import 'package:book_rent_app_chapter3/model/order.dart'; +import 'package:book_rent_app_chapter3/provider/user.dart'; class OrdersScreen extends StatelessWidget { @override diff --git a/lib/Screens/product_details.dart b/lib/Screens/product_details.dart index 339bca6..e2a6f7f 100644 --- a/lib/Screens/product_details.dart +++ b/lib/Screens/product_details.dart @@ -1,19 +1,20 @@ -import 'package:carousel_pro/carousel_pro.dart'; +import 'package:carousel_pro_nullsafety/carousel_pro_nullsafety.dart'; + import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/Screens/Loading.dart'; +import 'package:book_rent_app_chapter3/Screens/Loading.dart'; -import 'package:test_app/model/product.dart'; -import 'package:test_app/provider/app.dart'; -import 'package:test_app/provider/user.dart'; +import 'package:book_rent_app_chapter3/model/product.dart'; +import 'package:book_rent_app_chapter3/provider/app.dart'; +import 'package:book_rent_app_chapter3/provider/user.dart'; import 'package:uuid/uuid.dart'; -import 'package:test_app/services/order.dart'; +import 'package:book_rent_app_chapter3/services/order.dart'; class ProductDetails extends StatefulWidget { - final ProductModel product; - const ProductDetails({Key key, this.product}) : super(key: key); + final ProductModel? product; + const ProductDetails({ Key? key, this.product}) : super(key: key); @override _ProductDetailsState createState() => _ProductDetailsState(); @@ -27,7 +28,7 @@ class _ProductDetailsState extends State { @override void initState() { super.initState(); - size = widget.product.sizes[0]; + size = widget.product!.sizes[0]; } @override @@ -55,14 +56,14 @@ class _ProductDetailsState extends State { boxFit: BoxFit.cover, images: [ Image.network( - widget.product.pictures[0], + widget.product!.pictures[0], fit: BoxFit.fill, ), Image.network( - widget.product.pictures[1], + widget.product!.pictures[1], fit: BoxFit.fill, ), - Image.network(widget.product.pictures[2]), + Image.network(widget.product!.pictures[2]), ], animationCurve: Curves.fastOutSlowIn, dotSize: 4.0, @@ -86,7 +87,7 @@ class _ProductDetailsState extends State { child: DropdownButton( value: size, style: TextStyle(color: Colors.white), - items: widget.product.sizes + items: widget.product!.sizes .map>( (value) => DropdownMenuItem( value: value, @@ -97,7 +98,7 @@ class _ProductDetailsState extends State { .toList(), onChanged: (value) { setState(() { - size = value; + size = value!; }); }), ), @@ -139,10 +140,10 @@ class _ProductDetailsState extends State { _orderServices.createOrder( userId: userProvider.user.uid, id: id, - description: widget.product.name, + description: widget.product!.name, status: "ordered", totalPrice: pricef, - cart: userProvider.userModel.cart); + cart: userProvider.userModel.cart!); Navigator.pop(context); ScaffoldMessenger.of(_scaffoldContext).showSnackBar(SnackBar( content: Text("Order created!"))); @@ -195,7 +196,7 @@ class _ProductDetailsState extends State { onPressed: () async { appProvider.changeIsLoading(); bool success = await userProvider.addToCart( - product: widget.product, size: size); + product: widget.product!, size: size); if (success) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text("Added to Cart!"))); @@ -217,7 +218,7 @@ class _ProductDetailsState extends State { onPressed: () async { appProvider.changeIsLoading(); bool success = - await userProvider.addToFav(product: widget.product); + await userProvider.addToFav(product: widget.product!); if (success) { ScaffoldMessenger.of(context) .showSnackBar(SnackBar(content: Text("Added to Fav!"))); @@ -249,12 +250,12 @@ class _ProductDetailsState extends State { ], ), Divider(), - Text(widget.product.description), + Text(widget.product!.description), Divider(), Text('Why you should read?', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), Divider(), - Text(widget.product.whyToRead), + Text(widget.product!.whyToRead), Divider(), Text( 'Similar Books', @@ -274,25 +275,25 @@ class _ProductDetailsState extends State { switch (size) { case '1 week': return Text( - 'Price: ${widget.product.prices[0]}', + 'Price: ${widget.product!.prices[0]}', style: TextStyle(color: Colors.black, fontSize: 18), ); break; case '2 weeks': return Text( - 'Price: ${widget.product.prices[1]}', + 'Price: ${widget.product!.prices[1]}', style: TextStyle(color: Colors.black, fontSize: 18), ); break; case '3 weeks': return Text( - 'Price: ${widget.product.prices[2]}', + 'Price: ${widget.product!.prices[2]}', style: TextStyle(color: Colors.black, fontSize: 18), ); break; case '4 weeks': return Text( - 'Price: ${widget.product.prices[3]}', + 'Price: ${widget.product!.prices[3]}', style: TextStyle(color: Colors.black, fontSize: 18), ); break; @@ -304,16 +305,16 @@ class _ProductDetailsState extends State { prodPriceM() { switch (size) { case '1 week': - return widget.product.prices[0]; + return widget.product!.prices[0]; break; case '2 weeks': - return widget.product.prices[1]; + return widget.product!.prices[1]; break; case '3 weeks': - return widget.product.prices[2]; + return widget.product!.prices[2]; break; case '4 weeks': - return widget.product.prices[3]; + return widget.product!.prices[3]; break; default: return 0; diff --git a/lib/Screens/product_search.dart b/lib/Screens/product_search.dart index 9829a45..0a2d67c 100644 --- a/lib/Screens/product_search.dart +++ b/lib/Screens/product_search.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/Screens/product_details.dart'; -import 'package:test_app/Widgets.dart'; -import 'package:test_app/provider/product.dart'; +import 'package:book_rent_app_chapter3/Screens/product_details.dart'; +import 'package:book_rent_app_chapter3/Widgets.dart'; +import 'package:book_rent_app_chapter3/provider/product.dart'; class ProductSearchScreen extends StatelessWidget { @override diff --git a/lib/Utility/auth.dart b/lib/Utility/auth.dart index 0577646..a0e99f1 100644 --- a/lib/Utility/auth.dart +++ b/lib/Utility/auth.dart @@ -11,19 +11,14 @@ class Auth implements BaseAuth { @override Future googleSignIn() async { final GoogleSignIn _googleSignIn = GoogleSignIn(); - final GoogleSignInAccount googleAccount = await _googleSignIn.signIn(); + final GoogleSignInAccount? googleAccount = await _googleSignIn.signIn(); final GoogleSignInAuthentication googleAuth = - await googleAccount.authentication; + await googleAccount!.authentication; final AuthCredential credential = GoogleAuthProvider.credential( idToken: googleAuth.idToken, accessToken: googleAuth.accessToken); - try{ User user = (await _firebaseAuth.signInWithCredential(credential)) as User; return user; - }catch(e){ - print(e.toString()); - return null; - } } } \ No newline at end of file diff --git a/lib/Widgets.dart b/lib/Widgets.dart index 8267c3c..977eaf0 100644 --- a/lib/Widgets.dart +++ b/lib/Widgets.dart @@ -1,16 +1,16 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/Screens/Loading.dart'; -import 'package:test_app/Screens/allBooksofAGenre.dart'; -import 'package:test_app/Screens/product_details.dart'; -import 'package:test_app/model/product.dart'; -import 'package:test_app/provider/product.dart'; +import 'package:book_rent_app_chapter3/Screens/Loading.dart'; +import 'package:book_rent_app_chapter3/Screens/allBooksofAGenre.dart'; +import 'package:book_rent_app_chapter3/Screens/product_details.dart'; +import 'package:book_rent_app_chapter3/model/product.dart'; +import 'package:book_rent_app_chapter3/provider/product.dart'; import 'package:transparent_image/transparent_image.dart'; class CustomListTile extends StatelessWidget { final IconData icon; final String text; - final Function onTap; + final Function() onTap; CustomListTile(this.icon, this.text, this.onTap); @override @@ -50,7 +50,7 @@ class CustomListTile extends StatelessWidget { class ProductCard extends StatelessWidget { final ProductModel product; - const ProductCard({Key key, this.product}) : super(key: key); + const ProductCard({Key? key,required this.product}) : super(key: key); @override Widget build(BuildContext context) { @@ -71,7 +71,7 @@ class ProductCard extends StatelessWidget { borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( - color: Colors.grey[300], + color: Colors.grey[300]!, offset: Offset(-2, -1), blurRadius: 5), ]), @@ -473,7 +473,7 @@ class _ProductsState extends State { class FeaturedCard extends StatelessWidget { final ProductModel product; - const FeaturedCard({Key key, this.product}) : super(key: key); + const FeaturedCard({Key? key, required this.product}) : super(key: key); @override Widget build(BuildContext context) { @@ -573,7 +573,7 @@ class FeaturedCard extends StatelessWidget { class FeaturedProducts extends StatefulWidget { final String genre; - const FeaturedProducts({Key key, this.genre}) : super(key: key); + const FeaturedProducts({Key? key, required this.genre}) : super(key: key); @override _FeaturedProductsState createState() => _FeaturedProductsState(); @@ -628,7 +628,7 @@ class _FeaturedProductsState extends State { class PerGenre extends StatefulWidget { final String genre; - const PerGenre({Key key, this.genre}) : super(key: key); + const PerGenre({Key? key,required this.genre}) : super(key: key); @override _PerGenreState createState() => _PerGenreState(); @@ -658,7 +658,7 @@ class _PerGenreState extends State { class AllBooksOfAGenre extends StatefulWidget { final String genre; - const AllBooksOfAGenre({Key key, this.genre}) : super(key: key); + const AllBooksOfAGenre({Key? key, required this.genre}) : super(key: key); @override _AllBooksOfAGenreState createState() => _AllBooksOfAGenreState(); diff --git a/lib/main.dart b/lib/main.dart index c15d248..85ae17b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,14 +1,15 @@ import 'dart:async'; import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_app/Screens/LoginPage.dart'; -import 'package:test_app/Screens/NavBar.dart'; -import 'package:test_app/Screens/splash.dart'; -import 'package:test_app/provider/app.dart'; -import 'package:test_app/provider/product.dart'; -import 'package:test_app/provider/user.dart'; +import 'package:book_rent_app_chapter3/Screens/LoginPage.dart'; +import 'package:book_rent_app_chapter3/Screens/NavBar.dart'; +import 'package:book_rent_app_chapter3/Screens/splash.dart'; +import 'package:book_rent_app_chapter3/provider/app.dart'; +import 'package:book_rent_app_chapter3/provider/product.dart'; +import 'package:book_rent_app_chapter3/provider/user.dart'; import 'package:flutter/services.dart'; Future main() async { @@ -16,13 +17,26 @@ Future main() async { // Preload all assets to prevent flash when they are loaded. binding.deferFirstFrame(); binding.addPostFrameCallback((_) { - BuildContext context = binding.renderViewElement; + BuildContext context = binding.renderViewElement!; if (context != null) { Splash(); } binding.allowFirstFrame(); }); - await Firebase.initializeApp(); + if (Firebase.apps.isEmpty) { + if (kIsWeb) + await Firebase.initializeApp( + options: const FirebaseOptions( + apiKey: "AIzaSyDKcTjW2TTKLHq-kKeuSGJda9cpipv8eFE", + appId: "1:212895190763:web:ce93ccbf38d7bf823678ae", + messagingSenderId: "212895190763", + projectId: "chapter3-3a6ab"), + ); + else + await Firebase.initializeApp(); + } else { + Firebase.app(); + } runApp(MyApp()); } diff --git a/lib/model/cart_item.dart b/lib/model/cart_item.dart index 0107153..1205597 100644 --- a/lib/model/cart_item.dart +++ b/lib/model/cart_item.dart @@ -7,25 +7,25 @@ class CartItemModel { static const SIZE = "size"; //static const COLOR = "color"; - String _id; - String _name; - String _image; - String _productId; - String _size; + String? _id; + String? _name; + String? _image; + String? _productId; + String? _size; //String _color; - double _price; + double? _price; - String get id => _id; + String get id => _id!; - String get name => _name; + String get name => _name!; - String get image => _image; + String get image => _image!; - String get productId => _productId; + String get productId => _productId!; - String get size => _size; + String get size => _size!; - double get price => _price; + double get price => _price!; CartItemModel.fromMap(Map data) { _id = data[ID]; diff --git a/lib/model/fav.dart b/lib/model/fav.dart index 40c81dc..8039489 100644 --- a/lib/model/fav.dart +++ b/lib/model/fav.dart @@ -5,21 +5,21 @@ class FavItemModel { static const PRODUCT_ID = "productId"; static const PRICE = "price"; - String _id; - String _name; - String _image; - String _productId; - double _price; + String? _id; + String? _name; + String? _image; + String? _productId; + double? _price; - String get id => _id; + String get id => _id!; - String get name => _name; + String get name => _name!; - String get image => _image; + String get image => _image!; - String get productId => _productId; + String get productId => _productId!; - double get price => _price; + double get price => _price!; FavItemModel.fromMap(Map data) { _id = data[ID]; diff --git a/lib/model/order.dart b/lib/model/order.dart index 32af4e0..3e555fe 100644 --- a/lib/model/order.dart +++ b/lib/model/order.dart @@ -9,34 +9,34 @@ class OrderModel { static const STATUS = "status"; static const CREATED_AT = "createdAt"; - String _id; - String _description; - String _userId; - String _status; - int _createdAt; - double _total; + String? _id; + String? _description; + String? _userId; + String? _status; + int? _createdAt; + double? _total; - String get id => _id; + String get id => _id!; - String get description => _description; + String get description => _description!; - String get userId => _userId; + String get userId => _userId!; - String get status => _status; + String get status => _status!; - double get total => _total; + double get total => _total!; - int get createdAt => _createdAt; + int get createdAt => _createdAt!; - List cart; + List? cart; OrderModel.fromSnapshot(DocumentSnapshot snapshot) { - _id = snapshot.data()[ID]; - _description = snapshot.data()[DESCRIPTION]; - _total = snapshot.data()[TOTAL]; - _status = snapshot.data()[STATUS]; - _userId = snapshot.data()[USER_ID]; - _createdAt = snapshot.data()[CREATED_AT]; - cart = snapshot.data()[CART]; + _id = (snapshot.data()! as Map)[ID]; + _description = (snapshot.data()! as Map)[DESCRIPTION]; + _total = (snapshot.data()! as Map)[TOTAL]; + _status = (snapshot.data()! as Map)[STATUS]; + _userId = (snapshot.data()! as Map)[USER_ID]; + _createdAt = (snapshot.data()! as Map)[CREATED_AT]; + cart = (snapshot.data()! as Map)[CART]; } } diff --git a/lib/model/product.dart b/lib/model/product.dart index b3f15e8..8925823 100644 --- a/lib/model/product.dart +++ b/lib/model/product.dart @@ -17,62 +17,62 @@ class ProductModel { static const RECOMMENDED = "recommended"; static const BESTSELLER = "bestseller"; - String _id; - String _name; - List _pictures; - String _description; - String _genre; - String _author; - int _quantity; - List _prices; + String? _id; + String? _name; + List? _pictures; + String? _description; + String? _genre; + String? _author; + int? _quantity; + List? _prices; - bool _featured; - bool _recommended; - bool _bestseller; + bool? _featured; + bool? _recommended; + bool? _bestseller; - List _sizes; - String _whyToRead; + List? _sizes; + String? _whyToRead; - String get id => _id; + String get id => _id!; - String get name => _name; + String get name => _name!; - List get pictures => _pictures; + List get pictures => _pictures!; - String get author => _author; + String get author => _author!; - String get genre => _genre; + String get genre => _genre!; - String get description => _description; + String get description => _description!; - int get quantity => _quantity; + int get quantity => _quantity!; - List get prices => _prices; + List get prices => _prices!; - bool get featured => _featured; + bool get featured => _featured!; - bool get recommended => _recommended; + bool get recommended => _recommended!; - bool get bestseller => _bestseller; + bool get bestseller => _bestseller!; - List get sizes => _sizes; + List get sizes => _sizes!; - String get whyToRead => _whyToRead; + String get whyToRead => _whyToRead!; ProductModel.fromSnapshot(DocumentSnapshot snapshot) { - _id = snapshot.data()[ID]; - _author = snapshot.data()[AUTHOR]; + _id = (snapshot.data()! as Map)[ID]; + _author = (snapshot.data()! as Map)[AUTHOR]; //_sale = snapshot.data[SALE]; - _description = snapshot.data()[DESCRIPTION]; - _whyToRead = snapshot.data()[WHYTOREAD]; - _featured = snapshot.data()[FEATURED]; - _recommended = snapshot.data()[RECOMMENDED]; - _bestseller = snapshot.data()[BESTSELLER]; - _prices = snapshot.data()[PRICES]; - _genre = snapshot.data()[GENRE]; - - _sizes = snapshot.data()[SIZES]; - _name = snapshot.data()[NAME]; - _pictures = snapshot.data()[PICTURES]; + _description = (snapshot.data()! as Map)[DESCRIPTION]; + _whyToRead = (snapshot.data()! as Map)[WHYTOREAD]; + _featured = (snapshot.data()! as Map)[FEATURED]; + _recommended = (snapshot.data()! as Map)[RECOMMENDED]; + _bestseller = (snapshot.data()! as Map)[BESTSELLER]; + _prices = (snapshot.data()! as Map)[PRICES]; + _genre = (snapshot.data()! as Map)[GENRE]; + + _sizes = (snapshot.data()! as Map)[SIZES]; + _name = (snapshot.data()! as Map)[NAME]; + _pictures = (snapshot.data()! as Map)[PICTURES]; } } diff --git a/lib/model/user.dart b/lib/model/user.dart index 871b71c..860ef33 100644 --- a/lib/model/user.dart +++ b/lib/model/user.dart @@ -15,51 +15,51 @@ class UserModel { static const USERIMAGE = 'userImage'; static const BIO = 'bio'; - String _name; - String _email; - String _id; - String _stripeId; - String _number; - String _address; - String _userImage; - String _bio; - double _priceSum = 0; + String? _name; + String? _email; + String? _id; + String? _stripeId; + String? _number; + String? _address; + String? _userImage; + String? _bio; + double? _priceSum = 0; // getters - String get name => _name; + String get name => _name!; - String get email => _email; + String get email => _email!; - String get id => _id; + String get id => _id!; - String get stripeId => _stripeId; + String get stripeId => _stripeId!; - String get number => _number; + String get number => _number!; - String get address => _address; + String get address => _address!; - String get userImage => _userImage; + String get userImage => _userImage!; - String get bio => _bio; + String get bio => _bio!; - List cart; - List fav; - double totalCartPrice; + List? cart; + List? fav; + double? totalCartPrice; UserModel.fromSnapshot(DocumentSnapshot snapshot) { - _name = snapshot.data()[NAME]; - _email = snapshot.data()[EMAIL]; - _id = snapshot.data()[ID]; - _address = snapshot.data()[ADDRESS] ?? ""; - _number = snapshot.data()[NUMBER] ?? ''; - _userImage = snapshot.data()[USERIMAGE] ?? ""; - _stripeId = snapshot.data()[STRIPE_ID] ?? ""; - _bio = snapshot.data()[BIO] ?? ""; - cart = _convertCartItems(snapshot.data()[CART] ?? []); - fav = _convertFavItems(snapshot.data()[FAV] ?? []); - totalCartPrice = snapshot.data()[CART] == null + _name = (snapshot.data()! as Map)[NAME]; + _email = (snapshot.data()! as Map)[EMAIL]; + _id = (snapshot.data()! as Map)[ID]; + _address = (snapshot.data()! as Map)[ADDRESS] ?? ""; + _number = (snapshot.data()! as Map)[NUMBER] ?? ''; + _userImage = (snapshot.data()! as Map)[USERIMAGE] ?? ""; + _stripeId = (snapshot.data()! as Map)[STRIPE_ID] ?? ""; + _bio = (snapshot.data()! as Map)[BIO] ?? ""; + cart = _convertCartItems((snapshot.data()! as Map)[CART] ?? []); + fav = _convertFavItems((snapshot.data()! as Map)[FAV] ?? []); + totalCartPrice = (snapshot.data()! as Map)[CART] == null ? 0 - : getTotalPrice(cart: snapshot.data()[CART]); + : getTotalPrice(cart: (snapshot.data()! as Map)[CART]); } List _convertCartItems(List cart) { @@ -78,15 +78,15 @@ class UserModel { return convertedFav; } - double getTotalPrice({List cart}) { + double getTotalPrice({List? cart}) { if (cart == null) { return 0; } for (Map cartItem in cart) { - _priceSum += cartItem["price"]; + _priceSum = _priceSum! + cartItem["price"]; } - double total = _priceSum; - return total; + double? total = _priceSum; + return total!; } } diff --git a/lib/provider/product.dart b/lib/provider/product.dart index 87a2869..6ee60c6 100644 --- a/lib/provider/product.dart +++ b/lib/provider/product.dart @@ -1,5 +1,5 @@ -import 'package:test_app/model/product.dart'; -import 'package:test_app/services/product.dart'; +import 'package:book_rent_app_chapter3/model/product.dart'; +import 'package:book_rent_app_chapter3/services/product.dart'; import 'package:flutter/material.dart'; class ProductProvider with ChangeNotifier { @@ -16,7 +16,7 @@ class ProductProvider with ChangeNotifier { notifyListeners(); } - Future search({String productName}) async { + Future search({required String productName}) async { productsSearched = await _productServices.searchProducts(productName: productName); notifyListeners(); diff --git a/lib/provider/user.dart b/lib/provider/user.dart index 903482e..d57b570 100644 --- a/lib/provider/user.dart +++ b/lib/provider/user.dart @@ -1,33 +1,33 @@ import 'dart:async'; -import 'package:test_app/model/cart_item.dart'; -import 'package:test_app/model/order.dart'; -import 'package:test_app/model/product.dart'; -import 'package:test_app/model/user.dart'; -import 'package:test_app/services/order.dart'; -import 'package:test_app/services/user.dart'; +import 'package:book_rent_app_chapter3/model/cart_item.dart'; +import 'package:book_rent_app_chapter3/model/order.dart'; +import 'package:book_rent_app_chapter3/model/product.dart'; +import 'package:book_rent_app_chapter3/model/user.dart'; +import 'package:book_rent_app_chapter3/services/order.dart'; +import 'package:book_rent_app_chapter3/services/user.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:uuid/uuid.dart'; -import 'package:test_app/model/fav.dart'; +import 'package:book_rent_app_chapter3/model/fav.dart'; enum Status { Uninitialized, Authenticated, Authenticating, Unauthenticated } class UserProvider with ChangeNotifier { FirebaseAuth _auth; - User _user; + User? _user; Status _status = Status.Uninitialized; UserServices _userServices = UserServices(); OrderServices _orderServices = OrderServices(); - UserModel _userModel; + UserModel? _userModel; - UserModel get userModel => _userModel; + UserModel get userModel => _userModel!; Status get status => _status; - User get user => _user; + User get user => _user!; List orders = []; @@ -42,7 +42,7 @@ class UserProvider with ChangeNotifier { await _auth .signInWithEmailAndPassword(email: email, password: password) .then((value) async { - _userModel = await _userServices.getUserById(value.user.uid); + _userModel = await _userServices.getUserById(value.user!.uid); notifyListeners(); }); return true; @@ -65,14 +65,14 @@ class UserProvider with ChangeNotifier { _userServices.createUser({ 'name': name, 'email': email, - 'uid': user.user.uid, + 'uid': user.user!.uid, 'stripeId': '', 'number': '', 'address': '', 'bio': '', 'userImage': '', }); - _userModel = await _userServices.getUserById(user.user.uid); + _userModel = await _userServices.getUserById(user.user!.uid); notifyListeners(); }); return true; @@ -117,7 +117,7 @@ class UserProvider with ChangeNotifier { return Future.delayed(Duration.zero); } - Future _onStateChanged(User user) async { + Future _onStateChanged(User? user) async { if (user == null) { _status = Status.Unauthenticated; } else { @@ -128,11 +128,11 @@ class UserProvider with ChangeNotifier { notifyListeners(); } - Future addToCart({ProductModel product, String size}) async { + Future addToCart({required ProductModel product, required String size}) async { try { var uuid = Uuid(); String cartItemId = uuid.v4(); - List cart = _userModel.cart; + List cart = _userModel!.cart!; Map cartItem = { "id": cartItemId, @@ -146,7 +146,7 @@ class UserProvider with ChangeNotifier { CartItemModel item = CartItemModel.fromMap(cartItem); print("CART ITEMS ARE: ${cart.toString()}"); - _userServices.addToCart(userId: _user.uid, cartItem: item); + _userServices.addToCart(userId: _user!.uid, cartItem: item); return true; } catch (e) { @@ -155,20 +155,20 @@ class UserProvider with ChangeNotifier { } } - Future removeFromCart({CartItemModel cartItem}) async { + Future removeFromCart({required CartItemModel cartItem}) async { try { - _userServices.removeFromCart(userId: _user.uid, cartItem: cartItem); + _userServices.removeFromCart(userId: _user!.uid, cartItem: cartItem); return true; } catch (e) { return false; } } - Future addToFav({ProductModel product}) async { + Future addToFav({required ProductModel product}) async { try { var uuid = Uuid(); String favItemId = uuid.v4(); - List fav = _userModel.fav; + List fav = _userModel!.fav!; Map favItem = { "id": favItemId, @@ -181,7 +181,7 @@ class UserProvider with ChangeNotifier { FavItemModel item = FavItemModel.fromMap(favItem); print("CART ITEMS ARE: ${fav.toString()}"); - _userServices.addToFav(userId: _user.uid, favItem: item); + _userServices.addToFav(userId: _user!.uid, favItem: item); return true; } catch (e) { @@ -190,9 +190,9 @@ class UserProvider with ChangeNotifier { } } - Future removeFromFav({FavItemModel favItem}) async { + Future removeFromFav({required FavItemModel favItem}) async { try { - _userServices.removeFromFav(userId: _user.uid, favItem: favItem); + _userServices.removeFromFav(userId: _user!.uid, favItem: favItem); return true; } catch (e) { return false; @@ -200,7 +200,7 @@ class UserProvider with ChangeNotifier { } getOrders() async { - orders = await _orderServices.getUserOrders(userId: _user.uid); + orders = await _orderServices.getUserOrders(userId: _user!.uid); notifyListeners(); } @@ -209,7 +209,7 @@ class UserProvider with ChangeNotifier { notifyListeners(); } - prodPrice({ProductModel product, String size}) { + prodPrice({required ProductModel product,required String size}) { switch (size) { case '1 week': return product.prices[0]; diff --git a/lib/services/order.dart b/lib/services/order.dart index 07877dc..3c3a82c 100644 --- a/lib/services/order.dart +++ b/lib/services/order.dart @@ -1,5 +1,5 @@ -import 'package:test_app/model/cart_item.dart'; -import 'package:test_app/model/order.dart'; +import 'package:book_rent_app_chapter3/model/cart_item.dart'; +import 'package:book_rent_app_chapter3/model/order.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; class OrderServices { @@ -7,12 +7,12 @@ class OrderServices { FirebaseFirestore _firestore = FirebaseFirestore.instance; void createOrder( - {String userId, - String id, - String description, - String status, - List cart, - double totalPrice}) { + {required String userId, + required String id, + required String description, + required String status, + required List cart, + required double totalPrice}) { List convertedCart = []; for (CartItemModel item in cart) { @@ -30,7 +30,7 @@ class OrderServices { }); } - Future> getUserOrders({String userId}) async => _firestore + Future> getUserOrders({required String userId}) async => _firestore .collection(collection) .where("userId", isEqualTo: userId) .get() diff --git a/lib/services/product.dart b/lib/services/product.dart index 4674e74..c284517 100644 --- a/lib/services/product.dart +++ b/lib/services/product.dart @@ -1,4 +1,4 @@ -import 'package:test_app/model/product.dart'; +import 'package:book_rent_app_chapter3/model/product.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; class ProductServices { @@ -14,7 +14,7 @@ class ProductServices { return products; }); - Future> searchProducts({String productName}) { + Future> searchProducts({required String productName}) { String searchKey = productName[0].toLowerCase() + productName.substring(1); return _firestore .collection(collection) diff --git a/lib/services/user.dart b/lib/services/user.dart index 0e66cf6..067cb54 100644 --- a/lib/services/user.dart +++ b/lib/services/user.dart @@ -1,8 +1,8 @@ import 'dart:async'; -import 'package:test_app/model/cart_item.dart'; -import 'package:test_app/model/user.dart'; +import 'package:book_rent_app_chapter3/model/cart_item.dart'; +import 'package:book_rent_app_chapter3/model/user.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:test_app/model/fav.dart'; +import 'package:book_rent_app_chapter3/model/fav.dart'; class UserServices { FirebaseFirestore _firestore = FirebaseFirestore.instance; @@ -33,25 +33,25 @@ class UserServices { return UserModel.fromSnapshot(doc); }); - void addToCart({String userId, CartItemModel cartItem}) { + void addToCart({required String userId,required CartItemModel cartItem}) { _firestore.collection(collection).doc(userId).update({ "cart": FieldValue.arrayUnion([cartItem.toMap()]) }); } - void addToFav({String userId, FavItemModel favItem}) { + void addToFav({required String userId,required FavItemModel favItem}) { _firestore.collection(collection).doc(userId).update({ "fav": FieldValue.arrayUnion([favItem.toMap()]) }); } - void removeFromCart({String userId, CartItemModel cartItem}) { + void removeFromCart({required String userId,required CartItemModel cartItem}) { _firestore.collection(collection).doc(userId).update({ "cart": FieldValue.arrayRemove([cartItem.toMap()]) }); } - void removeFromFav({String userId, FavItemModel favItem}) { + void removeFromFav({required String userId,required FavItemModel favItem}) { _firestore.collection(collection).doc(userId).update({ "fav": FieldValue.arrayRemove([favItem.toMap()]) }); diff --git a/pubspec.lock b/pubspec.lock index a2c5782..9ad438e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -49,21 +49,21 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "1.0.7" + version: "3.1.5" cloud_firestore_platform_interface: dependency: transitive description: name: cloud_firestore_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.0.3" + version: "5.4.10" cloud_firestore_web: dependency: transitive description: name: cloud_firestore_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.7" + version: "2.6.5" collection: dependency: transitive description: @@ -120,13 +120,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.1.2" - firebase: - dependency: transitive - description: - name: firebase - url: "https://pub.dartlang.org" - source: hosted - version: "9.0.2" firebase_admob: dependency: "direct main" description: @@ -140,28 +133,28 @@ packages: name: firebase_analytics url: "https://pub.dartlang.org" source: hosted - version: "8.3.4" + version: "9.0.4" firebase_analytics_platform_interface: dependency: transitive description: name: firebase_analytics_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "3.0.3" firebase_analytics_web: dependency: transitive description: name: firebase_analytics_web url: "https://pub.dartlang.org" source: hosted - version: "0.3.0+1" + version: "0.4.0+4" firebase_auth: dependency: "direct main" description: name: firebase_auth url: "https://pub.dartlang.org" source: hosted - version: "3.3.0" + version: "3.3.4" firebase_auth_platform_interface: dependency: transitive description: @@ -182,7 +175,7 @@ packages: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "1.10.2" + version: "1.10.6" firebase_core_platform_interface: dependency: transitive description: @@ -203,28 +196,28 @@ packages: name: firebase_database url: "https://pub.dartlang.org" source: hosted - version: "8.2.0" + version: "9.0.4" firebase_database_platform_interface: dependency: transitive description: name: firebase_database_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "0.1.0+4" + version: "0.2.0+3" firebase_database_web: dependency: transitive description: name: firebase_database_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2+1" + version: "0.2.0+3" firebase_storage: dependency: "direct main" description: name: firebase_storage url: "https://pub.dartlang.org" source: hosted - version: "10.2.0" + version: "10.2.4" firebase_storage_platform_interface: dependency: transitive description: @@ -265,6 +258,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -278,7 +278,7 @@ packages: name: flutter_spinkit url: "https://pub.dartlang.org" source: hosted - version: "4.1.2+1" + version: "5.1.0" flutter_test: dependency: "direct dev" description: flutter @@ -290,7 +290,7 @@ packages: name: flutter_typeahead url: "https://pub.dartlang.org" source: hosted - version: "3.2.3" + version: "3.2.4" flutter_web_plugins: dependency: transitive description: flutter @@ -373,6 +373,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -659,5 +666,5 @@ packages: source: hosted version: "0.2.0" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.15.1 <3.0.0" flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1aac0c8..2ea86c8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,9 +1,9 @@ -name: test_app -description: A new Flutter application. +name: book_rent_app_chapter3 +description: A new Flutter project. # The following line prevents the package from being accidentally published to -# pub.dev using `pub publish`. This is preferred for private packages. -publish_to: "none" # Remove this line if you wish to publish to pub.dev +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -18,20 +18,25 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.15.1 <3.0.0" +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. dependencies: - carousel_pro: ^1.0.0 - cloud_firestore: 1.0.7 - curved_navigation_bar: 1.0.1 - firebase_admob: "^0.11.2" - firebase_analytics: 8.3.4 - firebase_auth: 3.3.0 - firebase_core: 1.10.2 - firebase_database: 8.2.0 - firebase_storage: 10.2.0 - flutter_spinkit: 4.1.2+1 - flutter_typeahead: 3.2.3 + carousel_pro_nullsafety: ^1.0.2 + cloud_firestore: 3.1.5 + curved_navigation_bar: ^1.0.1 + firebase_analytics: ^9.0.4 + firebase_auth: ^3.3.4 + firebase_core: 1.10.6 + firebase_database: ^9.0.4 + firebase_storage: ^10.2.4 + flutter_spinkit: ^5.1.0 + flutter_typeahead: ^3.2.4 fluttertoast: 8.0.8 google_sign_in: 5.2.1 http: 0.13.4 @@ -45,25 +50,37 @@ dependencies: flutter: sdk: flutter + # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.0 + cupertino_icons: ^1.0.2 dev_dependencies: flutter_test: sdk: flutter + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^1.0.0 + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: + # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg assets: - images/chapter3Logo.png - images/ProPic.jpeg diff --git a/test/widget_test.dart b/test/widget_test.dart new file mode 100644 index 0000000..88bc522 --- /dev/null +++ b/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:book_rent_app_chapter3/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..4a1da0b --- /dev/null +++ b/web/index.html @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + book_rent_app_chapter3 + + + + + + + + + + + + diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..ae5cf05 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "book_rent_app_chapter3", + "short_name": "book_rent_app_chapter3", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +}