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/app/build.gradle b/android/app/build.gradle index ab3a06e..23e1b49 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -27,7 +27,17 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -36,8 +46,8 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.flutter.udemy_flutter" - minSdkVersion 16 - targetSdkVersion 30 + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion multiDexEnabled true versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8b3b310..e803470 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -2,9 +2,12 @@ package="com.flutter.udemy_flutter"> + android:name="${applicationName}" + android:icon="@mipmap/ic_launcher"> /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # debugPrint error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ diff --git a/lib/layout/news_app/cubit/cubit.dart b/lib/layout/news_app/cubit/cubit.dart index 3ba2d28..42c595c 100644 --- a/lib/layout/news_app/cubit/cubit.dart +++ b/lib/layout/news_app/cubit/cubit.dart @@ -16,19 +16,19 @@ class NewsCubit extends Cubit List bottomItems = [ - BottomNavigationBarItem( + const BottomNavigationBarItem( icon: Icon( Icons.business, ), label: 'Business', ), - BottomNavigationBarItem( + const BottomNavigationBarItem( icon: Icon( Icons.sports, ), label: 'Sports', ), - BottomNavigationBarItem( + const BottomNavigationBarItem( icon: Icon( Icons.science, ), @@ -38,22 +38,24 @@ class NewsCubit extends Cubit List screens = [ - BusinessScreen(), - SportsScreen(), - ScienceScreen(), + const BusinessScreen(), + const SportsScreen(), + const ScienceScreen(), ]; void changeBottomNavBar(int index) { currentIndex = index; - if(index == 1) + if(index == 1) { getSports(); - if(index == 2) + } + if(index == 2) { getScience(); + } emit(NewsBottomNavState()); } - List business = []; + List? business = []; void getBusiness() { @@ -69,24 +71,24 @@ class NewsCubit extends Cubit }, ).then((value) { - //print(value.data['articles'][0]['title']); + //debugPrint(value.data['articles'][0]['title']); business = value.data['articles']; - print(business[0]['title']); + debugPrint(business![0]['title']); emit(NewsGetBusinessSuccessState()); }).catchError((error){ - print(error.toString()); + debugPrint(error.toString()); emit(NewsGetBusinessErrorState(error.toString())); }); } - List sports = []; + List? sports = []; void getSports() { emit(NewsGetSportsLoadingState()); - if(sports.length == 0) + if(sports!.isEmpty) { DioHelper.getData( url: 'v2/top-headlines', @@ -98,13 +100,13 @@ class NewsCubit extends Cubit }, ).then((value) { - //print(value.data['articles'][0]['title']); + //debugPrint(value.data['articles'][0]['title']); sports = value.data['articles']; - print(sports[0]['title']); + debugPrint(sports![0]['title']); emit(NewsGetSportsSuccessState()); }).catchError((error){ - print(error.toString()); + debugPrint(error.toString()); emit(NewsGetSportsErrorState(error.toString())); }); } else @@ -113,13 +115,13 @@ class NewsCubit extends Cubit } } - List science = []; + List? science = []; void getScience() { emit(NewsGetScienceLoadingState()); - if(science.length == 0) + if(science!.isEmpty) { DioHelper.getData( url: 'v2/top-headlines', @@ -131,13 +133,13 @@ class NewsCubit extends Cubit }, ).then((value) { - //print(value.data['articles'][0]['title']); + //debugPrint(value.data['articles'][0]['title']); science = value.data['articles']; - print(science[0]['title']); + debugPrint(science![0]['title']); emit(NewsGetScienceSuccessState()); }).catchError((error){ - print(error.toString()); + debugPrint(error.toString()); emit(NewsGetScienceErrorState(error.toString())); }); } else @@ -146,7 +148,7 @@ class NewsCubit extends Cubit } } - List search = []; + List? search = []; void getSearch(String value) { @@ -156,18 +158,18 @@ class NewsCubit extends Cubit url: 'v2/everything', query: { - 'q':'$value', + 'q':value, 'apiKey':'65f7f556ec76449fa7dc7c0069f040ca', }, ).then((value) { - //print(value.data['articles'][0]['title']); + //debugPrint(value.data['articles'][0]['title']); search = value.data['articles']; - print(search[0]['title']); + debugPrint(search![0]['title']); emit(NewsGetSearchSuccessState()); }).catchError((error){ - print(error.toString()); + debugPrint(error.toString()); emit(NewsGetSearchErrorState(error.toString())); }); } diff --git a/lib/layout/news_app/news_layout.dart b/lib/layout/news_app/news_layout.dart index 1d15ba3..107c7f4 100644 --- a/lib/layout/news_app/news_layout.dart +++ b/lib/layout/news_app/news_layout.dart @@ -7,35 +7,37 @@ import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/cubit/cubit.dart'; class NewsLayout extends StatelessWidget { + const NewsLayout({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BlocConsumer( listener: (context, state) {}, - builder: (context, state) - { + builder: (context, state) { var cubit = NewsCubit.get(context); return Scaffold( appBar: AppBar( - title: Text( + title: const Text( 'News App', ), actions: [ IconButton( - icon: Icon( + icon: const Icon( Icons.search, ), - onPressed: () - { - navigateTo(context, SearchScreen(),); + onPressed: () { + navigateTo( + context, + const SearchScreen(), + ); }, ), IconButton( - icon: Icon( + icon: const Icon( Icons.brightness_4_outlined, ), - onPressed: () - { + onPressed: () { AppCubit.get(context).changeAppMode(); }, ), diff --git a/lib/layout/shop_app/cubit/cubit.dart b/lib/layout/shop_app/cubit/cubit.dart index 1285801..8d38f75 100644 --- a/lib/layout/shop_app/cubit/cubit.dart +++ b/lib/layout/shop_app/cubit/cubit.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -10,7 +9,6 @@ import 'package:udemy_flutter/models/shop_app/home_model.dart'; import 'package:udemy_flutter/models/shop_app/login_model.dart'; import 'package:udemy_flutter/modules/shop_app/cateogries/categories_screen.dart'; import 'package:udemy_flutter/modules/shop_app/favorites/favorites_screen.dart'; -import 'package:udemy_flutter/modules/shop_app/login/cubit/cubit.dart'; import 'package:udemy_flutter/modules/shop_app/products/products_screen.dart'; import 'package:udemy_flutter/modules/shop_app/settings/settings_screen.dart'; import 'package:udemy_flutter/shared/components/constants.dart'; @@ -25,10 +23,10 @@ class ShopCubit extends Cubit { int currentIndex = 0; List bottomScreens = [ - ProductsScreen(), - CategoriesScreen(), - FavoritesScreen(), - SettingsScreen(), + const ProductsScreen(), + const CategoriesScreen(), + const FavoritesScreen(), + const SettingsScreen(), ]; void changeBottom(int index) { @@ -36,90 +34,90 @@ class ShopCubit extends Cubit { emit(ShopChangeBottomNavState()); } - HomeModel homeModel; + HomeModel? homeModel; - Map favorites = {}; + Map favorites = {}; void getHomeData() { emit(ShopLoadingHomeDataState()); DioHelper.getData( - url: HOME, + url: kHOME, token: token, ).then((value) { homeModel = HomeModel.fromJson(value.data); - //print(homeModel.data.banners[0].image); - //print(homeModel.status); + //debugPrint(homeModel.data.banners[0].image); + //debugPrint(homeModel.status); - homeModel.data.products.forEach((element) { + for (var element in homeModel!.data.products) { favorites.addAll({ element.id: element.inFavorites, }); - }); + } - //print(favorites.toString()); + //debugPrint(favorites.toString()); emit(ShopSuccessHomeDataState()); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(ShopErrorHomeDataState()); }); } - CategoriesModel categoriesModel; + CategoriesModel? categoriesModel; void getCategories() { DioHelper.getData( - url: GET_CATEGORIES, + url: kGetCATEGORIES, ).then((value) { categoriesModel = CategoriesModel.fromJson(value.data); emit(ShopSuccessCategoriesState()); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(ShopErrorCategoriesState()); }); } - ChangeFavoritesModel changeFavoritesModel; + ChangeFavoritesModel? changeFavoritesModel; - void changeFavorites(int productId) { - favorites[productId] = !favorites[productId]; + void changeFavorites(int? productId) { + favorites[productId] = !favorites[productId]!; emit(ShopChangeFavoritesState()); DioHelper.postData( - url: FAVORITES, + url: kFAVORITES, data: { 'product_id': productId, }, token: token, ).then((value) { changeFavoritesModel = ChangeFavoritesModel.fromJson(value.data); - print(value.data); + debugPrint(value.data); - if (!changeFavoritesModel.status) { - favorites[productId] = !favorites[productId]; + if (!changeFavoritesModel!.status!) { + favorites[productId] = !favorites[productId]!; } else { getFavorites(); } emit(ShopSuccessChangeFavoritesState(changeFavoritesModel)); }).catchError((error) { - favorites[productId] = !favorites[productId]; + favorites[productId] = !favorites[productId]!; emit(ShopErrorChangeFavoritesState()); }); } - FavoritesModel favoritesModel; + late FavoritesModel favoritesModel; void getFavorites() { emit(ShopLoadingGetFavoritesState()); DioHelper.getData( - url: FAVORITES, + url: kFAVORITES, token: token, ).then((value) { favoritesModel = FavoritesModel.fromJson(value.data); @@ -127,39 +125,39 @@ class ShopCubit extends Cubit { emit(ShopSuccessGetFavoritesState()); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(ShopErrorGetFavoritesState()); }); } - ShopLoginModel userModel; + ShopLoginModel? userModel; void getUserData() { emit(ShopLoadingUserDataState()); DioHelper.getData( - url: PROFILE, + url: kPROFILE, token: token, ).then((value) { userModel = ShopLoginModel.fromJson(value.data); - printFullText(userModel.data.name); + printFullText(userModel!.data!.name!); emit(ShopSuccessUserDataState(userModel)); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(ShopErrorUserDataState()); }); } void updateUserData({ - @required String name, - @required String email, - @required String phone, + required String name, + required String email, + required String phone, }) { emit(ShopLoadingUpdateUserState()); DioHelper.putData( - url: UPDATE_PROFILE, + url: kUpdatePROFILE, token: token, data: { 'name': name, @@ -168,11 +166,11 @@ class ShopCubit extends Cubit { }, ).then((value) { userModel = ShopLoginModel.fromJson(value.data); - printFullText(userModel.data.name); + printFullText(userModel!.data!.name!); emit(ShopSuccessUpdateUserState(userModel)); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(ShopErrorUpdateUserState()); }); } diff --git a/lib/layout/shop_app/cubit/states.dart b/lib/layout/shop_app/cubit/states.dart index 5696ee8..f959304 100644 --- a/lib/layout/shop_app/cubit/states.dart +++ b/lib/layout/shop_app/cubit/states.dart @@ -21,7 +21,7 @@ class ShopChangeFavoritesState extends ShopStates {} class ShopSuccessChangeFavoritesState extends ShopStates { - final ChangeFavoritesModel model; + final ChangeFavoritesModel? model; ShopSuccessChangeFavoritesState(this.model); } @@ -38,7 +38,7 @@ class ShopLoadingUserDataState extends ShopStates {} class ShopSuccessUserDataState extends ShopStates { - final ShopLoginModel loginModel; + final ShopLoginModel? loginModel; ShopSuccessUserDataState(this.loginModel); } @@ -49,7 +49,7 @@ class ShopLoadingUpdateUserState extends ShopStates {} class ShopSuccessUpdateUserState extends ShopStates { - final ShopLoginModel loginModel; + final ShopLoginModel? loginModel; ShopSuccessUpdateUserState(this.loginModel); } diff --git a/lib/layout/shop_app/shop_layout.dart b/lib/layout/shop_app/shop_layout.dart index 195c207..4a60cd3 100644 --- a/lib/layout/shop_app/shop_layout.dart +++ b/lib/layout/shop_app/shop_layout.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/shop_app/cubit/cubit.dart'; import 'package:udemy_flutter/layout/shop_app/cubit/states.dart'; -import 'package:udemy_flutter/modules/shop_app/login/shop_login_screen.dart'; import 'package:udemy_flutter/modules/shop_app/search/search_screen.dart'; import 'package:udemy_flutter/shared/components/components.dart'; -import 'package:udemy_flutter/shared/network/local/cache_helper.dart'; class ShopLayout extends StatelessWidget { + const ShopLayout({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BlocConsumer( @@ -17,16 +17,16 @@ class ShopLayout extends StatelessWidget { return Scaffold( appBar: AppBar( - title: Text( + title: const Text( 'Salla', ), actions: [ IconButton( - icon: Icon( + icon: const Icon( Icons.search, ), onPressed: () { - navigateTo(context, SearchScreen(),); + navigateTo(context, const SearchScreen(),); }, ), ], @@ -37,7 +37,7 @@ class ShopLayout extends StatelessWidget { cubit.changeBottom(index); }, currentIndex: cubit.currentIndex, - items: [ + items: const [ BottomNavigationBarItem( icon: Icon( Icons.home, diff --git a/lib/layout/social_app/cubit/cubit.dart b/lib/layout/social_app/cubit/cubit.dart index 65b52e1..e031d84 100644 --- a/lib/layout/social_app/cubit/cubit.dart +++ b/lib/layout/social_app/cubit/cubit.dart @@ -22,17 +22,17 @@ class SocialCubit extends Cubit static SocialCubit get(context) => BlocProvider.of(context); - SocialUserModel userModel; + SocialUserModel? userModel; void getUserData() { emit(SocialGetUserLoadingState()); FirebaseFirestore.instance.collection('users').doc(uId).get().then((value) { - //print(value.data()); - userModel = SocialUserModel.fromJson(value.data()); + //debugPrint(value.data()); + userModel = SocialUserModel.fromJson(value.data()!); emit(SocialGetUserSuccessState()); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(SocialGetUserErrorState(error.toString())); }); } @@ -40,11 +40,11 @@ class SocialCubit extends Cubit int currentIndex = 0; List screens = [ - FeedsScreen(), - ChatsScreen(), - NewPostScreen(), - UsersScreen(), - SettingsScreen(), + const FeedsScreen(), + const ChatsScreen(), + const NewPostScreen(), + const UsersScreen(), + const SettingsScreen(), ]; List titles = [ @@ -57,38 +57,38 @@ class SocialCubit extends Cubit void changeBottomNav(int index) { if (index == 1) getUsers(); - if (index == 2) + if (index == 2) { emit(SocialNewPostState()); - else { + } else { currentIndex = index; emit(SocialChangeBottomNavState()); } } - File profileImage; + File? profileImage; var picker = ImagePicker(); Future getProfileImage() async { - final pickedFile = await picker.getImage( + final pickedFile = await picker.pickImage( source: ImageSource.gallery, ); if (pickedFile != null) { profileImage = File(pickedFile.path); - print(pickedFile.path); + debugPrint(pickedFile.path); emit(SocialProfileImagePickedSuccessState()); } else { - print('No image selected.'); + debugPrint('No image selected.'); emit(SocialProfileImagePickedErrorState()); } } // image_picker7901250412914563370.jpg - File coverImage; + File? coverImage; Future getCoverImage() async { - final pickedFile = await picker.getImage( + final pickedFile = await picker.pickImage( source: ImageSource.gallery, ); @@ -96,26 +96,26 @@ class SocialCubit extends Cubit coverImage = File(pickedFile.path); emit(SocialCoverImagePickedSuccessState()); } else { - print('No image selected.'); + debugPrint('No image selected.'); emit(SocialCoverImagePickedErrorState()); } } void uploadProfileImage({ - @required String name, - @required String phone, - @required String bio, + required String name, + required String phone, + required String bio, }) { emit(SocialUserUpdateLoadingState()); firebase_storage.FirebaseStorage.instance .ref() - .child('users/${Uri.file(profileImage.path).pathSegments.last}') - .putFile(profileImage) + .child('users/${Uri.file(profileImage!.path).pathSegments.last}') + .putFile(profileImage!) .then((value) { value.ref.getDownloadURL().then((value) { //emit(SocialUploadProfileImageSuccessState()); - print(value); + debugPrint(value); updateUser( name: name, phone: phone, @@ -131,20 +131,20 @@ class SocialCubit extends Cubit } void uploadCoverImage({ - @required String name, - @required String phone, - @required String bio, + required String name, + required String phone, + required String bio, }) { emit(SocialUserUpdateLoadingState()); firebase_storage.FirebaseStorage.instance .ref() - .child('users/${Uri.file(coverImage.path).pathSegments.last}') - .putFile(coverImage) + .child('users/${Uri.file(coverImage!.path).pathSegments.last}') + .putFile(coverImage!) .then((value) { value.ref.getDownloadURL().then((value) { //emit(SocialUploadCoverImageSuccessState()); - print(value); + debugPrint(value); updateUser( name: name, phone: phone, @@ -187,26 +187,26 @@ class SocialCubit extends Cubit // } void updateUser({ - @required String name, - @required String phone, - @required String bio, - String cover, - String image, + required String name, + required String phone, + required String bio, + String? cover, + String? image, }) { SocialUserModel model = SocialUserModel( name: name, phone: phone, bio: bio, - email: userModel.email, - cover: cover ?? userModel.cover, - image: image ?? userModel.image, - uId: userModel.uId, + email: userModel!.email, + cover: cover ?? userModel!.cover, + image: image ?? userModel!.image, + uId: userModel!.uId, isEmailVerified: false, ); FirebaseFirestore.instance .collection('users') - .doc(userModel.uId) + .doc(userModel!.uId) .update(model.toMap()) .then((value) { getUserData(); @@ -215,10 +215,10 @@ class SocialCubit extends Cubit }); } - File postImage; + File? postImage; Future getPostImage() async { - final pickedFile = await picker.getImage( + final pickedFile = await picker.pickImage( source: ImageSource.gallery, ); @@ -226,7 +226,7 @@ class SocialCubit extends Cubit postImage = File(pickedFile.path); emit(SocialPostImagePickedSuccessState()); } else { - print('No image selected.'); + debugPrint('No image selected.'); emit(SocialPostImagePickedErrorState()); } } @@ -237,18 +237,18 @@ class SocialCubit extends Cubit } void uploadPostImage({ - @required String dateTime, - @required String text, + required String dateTime, + required String text, }) { emit(SocialCreatePostLoadingState()); firebase_storage.FirebaseStorage.instance .ref() - .child('posts/${Uri.file(postImage.path).pathSegments.last}') - .putFile(postImage) + .child('posts/${Uri.file(postImage!.path).pathSegments.last}') + .putFile(postImage!) .then((value) { value.ref.getDownloadURL().then((value) { - print(value); + debugPrint(value); createPost( text: text, dateTime: dateTime, @@ -263,16 +263,16 @@ class SocialCubit extends Cubit } void createPost({ - @required String dateTime, - @required String text, - String postImage, + required String dateTime, + required String text, + String? postImage, }) { emit(SocialCreatePostLoadingState()); PostModel model = PostModel( - name: userModel.name, - image: userModel.image, - uId: userModel.uId, + name: userModel!.name, + image: userModel!.image, + uId: userModel!.uId, dateTime: dateTime, text: text, postImage: postImage ?? '', @@ -294,17 +294,17 @@ class SocialCubit extends Cubit void getPosts() { FirebaseFirestore.instance.collection('posts').get().then((value) { - value.docs.forEach((element) { + for (var element in value.docs) { element.reference.collection('likes').get().then((value) { likes.add(value.docs.length); postsId.add(element.id); posts.add(PostModel.fromJson(element.data())); }).catchError((error) {}); - }); + } emit(SocialGetPostsSuccessState()); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(SocialGetPostsErrorState(error.toString())); }); } @@ -314,7 +314,7 @@ class SocialCubit extends Cubit .collection('posts') .doc(postId) .collection('likes') - .doc(userModel.uId) + .doc(userModel!.uId) .set({ 'like': true, }).then((value) { @@ -327,28 +327,30 @@ class SocialCubit extends Cubit List users = []; void getUsers() { - if (users.length == 0) + if (users.isEmpty) { FirebaseFirestore.instance.collection('users').get().then((value) { - value.docs.forEach((element) { - if (element.data()['uId'] != userModel.uId) + for (var element in value.docs) { + if (element.data()['uId'] != userModel!.uId) { users.add(SocialUserModel.fromJson(element.data())); - }); + } + } emit(SocialGetAllUsersSuccessState()); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(SocialGetAllUsersErrorState(error.toString())); }); + } } void sendMessage({ - @required String receiverId, - @required String dateTime, - @required String text, + required String? receiverId, + required String dateTime, + required String text, }) { MessageModel model = MessageModel( text: text, - senderId: userModel.uId, + senderId: userModel!.uId, receiverId: receiverId, dateTime: dateTime, ); @@ -357,7 +359,7 @@ class SocialCubit extends Cubit FirebaseFirestore.instance .collection('users') - .doc(userModel.uId) + .doc(userModel!.uId) .collection('chats') .doc(receiverId) .collection('messages') @@ -374,7 +376,7 @@ class SocialCubit extends Cubit .collection('users') .doc(receiverId) .collection('chats') - .doc(userModel.uId) + .doc(userModel!.uId) .collection('messages') .add(model.toMap()) .then((value) { @@ -387,11 +389,11 @@ class SocialCubit extends Cubit List messages = []; void getMessages({ - @required String receiverId, + required String? receiverId, }) { FirebaseFirestore.instance .collection('users') - .doc(userModel.uId) + .doc(userModel!.uId) .collection('chats') .doc(receiverId) .collection('messages') @@ -400,9 +402,9 @@ class SocialCubit extends Cubit .listen((event) { messages = []; - event.docs.forEach((element) { + for (var element in event.docs) { messages.add(MessageModel.fromJson(element.data())); - }); + } emit(SocialGetMessagesSuccessState()); }); diff --git a/lib/layout/social_app/social_layout.dart b/lib/layout/social_app/social_layout.dart index 44208d7..d533af9 100644 --- a/lib/layout/social_app/social_layout.dart +++ b/lib/layout/social_app/social_layout.dart @@ -1,4 +1,3 @@ -import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/social_app/cubit/cubit.dart'; @@ -9,6 +8,8 @@ import 'package:udemy_flutter/shared/styles/icon_broken.dart'; class SocialLayout extends StatelessWidget { + const SocialLayout({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { @@ -17,7 +18,7 @@ class SocialLayout extends StatelessWidget if (state is SocialNewPostState) { navigateTo( context, - NewPostScreen(), + const NewPostScreen(), ); } }, @@ -32,14 +33,14 @@ class SocialLayout extends StatelessWidget ), actions: [ IconButton( - icon: Icon( - IconBroken.Notification, + icon: const Icon( + IconBroken.kNotification, ), onPressed: () {}, ), IconButton( - icon: Icon( - IconBroken.Search, + icon: const Icon( + IconBroken.kSearch, ), onPressed: () {}, ), @@ -52,34 +53,34 @@ class SocialLayout extends StatelessWidget { cubit.changeBottomNav(index); }, - items: [ + items: const [ BottomNavigationBarItem( icon: Icon( - IconBroken.Home, + IconBroken.kHome, ), label: 'Home', ), BottomNavigationBarItem( icon: Icon( - IconBroken.Chat, + IconBroken.kChat, ), label: 'Chats', ), BottomNavigationBarItem( icon: Icon( - IconBroken.Paper_Upload, + IconBroken.kPaperUpload, ), label: 'Post', ), BottomNavigationBarItem( icon: Icon( - IconBroken.Location, + IconBroken.kLocation, ), label: 'Users', ), BottomNavigationBarItem( icon: Icon( - IconBroken.Setting, + IconBroken.kSetting, ), label: 'Settings', ), diff --git a/lib/layout/todo_app/todo_layout.dart b/lib/layout/todo_app/todo_layout.dart index ea04d3a..749e05e 100644 --- a/lib/layout/todo_app/todo_layout.dart +++ b/lib/layout/todo_app/todo_layout.dart @@ -1,4 +1,4 @@ -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; @@ -15,21 +15,21 @@ import 'package:udemy_flutter/shared/cubit/states.dart'; // 7. delete from database class HomeLayout extends StatelessWidget { - var scaffoldKey = GlobalKey(); - var formKey = GlobalKey(); - var titleController = TextEditingController(); - var timeController = TextEditingController(); - var dateController = TextEditingController(); + const HomeLayout({Key? key}) : super(key: key); @override - Widget build(BuildContext context) - { + Widget build(BuildContext context) { + var scaffoldKey = GlobalKey(); + var formKey = GlobalKey(); + var titleController = TextEditingController(); + var timeController = TextEditingController(); + var dateController = TextEditingController(); + return BlocProvider( create: (BuildContext context) => AppCubit()..createDatabase(), child: BlocConsumer( listener: (BuildContext context, AppStates state) { - if(state is AppInsertDatabaseState) - { + if (state is AppInsertDatabaseState) { Navigator.pop(context); } }, @@ -46,27 +46,25 @@ class HomeLayout extends StatelessWidget { body: ConditionalBuilder( condition: state is! AppGetDatabaseLoadingState, builder: (context) => cubit.screens[cubit.currentIndex], - fallback: (context) => Center(child: CircularProgressIndicator()), + fallback: (context) => + const Center(child: CircularProgressIndicator()), ), floatingActionButton: FloatingActionButton( onPressed: () { - if (cubit.isBottomSheetShown) - { - if (formKey.currentState.validate()) - { + if (cubit.isBottomSheetShown) { + if (formKey.currentState!.validate()) { cubit.insertToDatabase( title: titleController.text, time: timeController.text, date: dateController.text, ); } - } else - { - scaffoldKey.currentState + } else { + scaffoldKey.currentState! .showBottomSheet( (context) => Container( color: Colors.white, - padding: EdgeInsets.all( + padding: const EdgeInsets.all( 20.0, ), child: Form( @@ -87,7 +85,7 @@ class HomeLayout extends StatelessWidget { label: 'Task Title', prefix: Icons.title, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( @@ -99,8 +97,8 @@ class HomeLayout extends StatelessWidget { initialTime: TimeOfDay.now(), ).then((value) { timeController.text = - value.format(context).toString(); - print(value.format(context)); + value!.format(context).toString(); + debugPrint(value.format(context)); }); }, validate: (String value) { @@ -113,7 +111,7 @@ class HomeLayout extends StatelessWidget { label: 'Task Time', prefix: Icons.watch_later_outlined, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( @@ -127,7 +125,7 @@ class HomeLayout extends StatelessWidget { lastDate: DateTime.parse('2021-05-03'), ).then((value) { dateController.text = - DateFormat.yMMMd().format(value); + DateFormat.yMMMd().format(value!); }); }, validate: (String value) { @@ -147,8 +145,7 @@ class HomeLayout extends StatelessWidget { elevation: 20.0, ) .closed - .then((value) - { + .then((value) { cubit.changeBottomSheetState( isShow: false, icon: Icons.edit, @@ -171,7 +168,7 @@ class HomeLayout extends StatelessWidget { onTap: (index) { cubit.changeIndex(index); }, - items: [ + items: const [ BottomNavigationBarItem( icon: Icon( Icons.menu, @@ -204,4 +201,4 @@ class HomeLayout extends StatelessWidget { // { // return 'Ahmed Ali'; // } -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index c40b79f..f4043bf 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,20 +1,12 @@ -import 'package:bloc/bloc.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:hexcolor/hexcolor.dart'; import 'package:udemy_flutter/layout/news_app/cubit/cubit.dart'; -import 'package:udemy_flutter/layout/news_app/news_layout.dart'; import 'package:udemy_flutter/layout/shop_app/cubit/cubit.dart'; -import 'package:udemy_flutter/layout/shop_app/shop_layout.dart'; import 'package:udemy_flutter/layout/social_app/cubit/cubit.dart'; import 'package:udemy_flutter/layout/social_app/social_layout.dart'; -import 'package:udemy_flutter/modules/shop_app/login/shop_login_screen.dart'; -import 'package:udemy_flutter/modules/shop_app/on_boarding/on_boarding_screen.dart'; import 'package:udemy_flutter/modules/social_app/social_login/social_login_screen.dart'; -import 'package:udemy_flutter/shared/bloc_observer.dart'; import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/components/constants.dart'; import 'package:udemy_flutter/shared/cubit/cubit.dart'; @@ -25,10 +17,10 @@ import 'package:udemy_flutter/shared/styles/themes.dart'; Future firebaseMessagingBackgroundHandler(RemoteMessage message) async { - print('on background message'); - print(message.data.toString()); + debugPrint('on background message'); + debugPrint(message.data.toString()); - showToast(text: 'on background message', state: ToastStates.SUCCESS,); + showToast(text: 'on background message', state: ToastStates.kSUCCESS,); } void main() async @@ -39,34 +31,34 @@ void main() async await Firebase.initializeApp(); var token = await FirebaseMessaging.instance.getToken(); - print(token); + debugPrint(token); // foreground fcm FirebaseMessaging.onMessage.listen((event) { - print('on message'); - print(event.data.toString()); + debugPrint('on message'); + debugPrint(event.data.toString()); - showToast(text: 'on message', state: ToastStates.SUCCESS,); + showToast(text: 'on message', state: ToastStates.kSUCCESS,); }); // when click on notification to open app FirebaseMessaging.onMessageOpenedApp.listen((event) { - print('on message opened app'); - print(event.data.toString()); - showToast(text: 'on message opened app', state: ToastStates.SUCCESS,); + debugPrint('on message opened app'); + debugPrint(event.data.toString()); + showToast(text: 'on message opened app', state: ToastStates.kSUCCESS,); }); // background fcm FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); - Bloc.observer = MyBlocObserver(); + // Bloc.observer = MyBlocObserver(); DioHelper.init(); await CacheHelper.init(); - bool isDark = CacheHelper.getData(key: 'isDark'); + bool? isDark = CacheHelper.getData(key: 'isDark'); Widget widget; @@ -86,10 +78,10 @@ void main() async if(uId != null) { - widget = SocialLayout(); + widget = const SocialLayout(); } else { - widget = SocialLoginScreen(); + widget = const SocialLoginScreen(); } runApp(MyApp( @@ -107,13 +99,13 @@ class MyApp extends StatelessWidget { // constructor // build - final bool isDark; - final Widget startWidget; + final bool? isDark; + final Widget? startWidget; - MyApp({ + const MyApp({Key? key, this.isDark, this.startWidget, - }); + }) : super(key: key); @override Widget build(BuildContext context) @@ -147,7 +139,7 @@ class MyApp extends StatelessWidget theme: lightTheme, darkTheme: darkTheme, themeMode: ThemeMode.light, - home: SocialLayout(), + home: const SocialLayout(), ); }, ), diff --git a/lib/models/shop_app/categories_model.dart b/lib/models/shop_app/categories_model.dart index 04bdb81..2f4f1d7 100644 --- a/lib/models/shop_app/categories_model.dart +++ b/lib/models/shop_app/categories_model.dart @@ -1,7 +1,7 @@ class CategoriesModel { - bool status; - CategoriesDataModel data; + bool? status; + late CategoriesDataModel data; CategoriesModel.fromJson(Map json) { @@ -12,7 +12,7 @@ class CategoriesModel class CategoriesDataModel { - int currentPage; + int? currentPage; List data = []; CategoriesDataModel.fromJson(Map json) @@ -27,9 +27,9 @@ class CategoriesDataModel class DataModel { - int id; - String name; - String image; + int? id; + String? name; + String? image; DataModel.fromJson(Map json) { diff --git a/lib/models/shop_app/change_favorites_model.dart b/lib/models/shop_app/change_favorites_model.dart index 721dd6e..70f1853 100644 --- a/lib/models/shop_app/change_favorites_model.dart +++ b/lib/models/shop_app/change_favorites_model.dart @@ -1,7 +1,7 @@ class ChangeFavoritesModel { - bool status; - String message; + bool? status; + String? message; ChangeFavoritesModel.fromJson(Map json) { diff --git a/lib/models/shop_app/favorites_model.dart b/lib/models/shop_app/favorites_model.dart index 17748c3..6d6235a 100644 --- a/lib/models/shop_app/favorites_model.dart +++ b/lib/models/shop_app/favorites_model.dart @@ -1,37 +1,37 @@ class FavoritesModel { - bool status; - Null message; - Data data; + bool? status; + String? message; + Data? data; FavoritesModel.fromJson(Map json) { status = json['status']; message = json['message']; - data = json['data'] != null ? new Data.fromJson(json['data']) : null; + data = json['data'] != null ? Data.fromJson(json['data']) : null; } } class Data { - int currentPage; - List data; - String firstPageUrl; - int from; - int lastPage; - String lastPageUrl; - Null nextPageUrl; - String path; - int perPage; - Null prevPageUrl; - int to; - int total; + int? currentPage; + late List data; + String? firstPageUrl; + int? from; + int? lastPage; + String? lastPageUrl; + String? nextPageUrl; + String? path; + int? perPage; + String? prevPageUrl; + int? to; + int? total; Data.fromJson(Map json) { currentPage = json['current_page']; if (json['data'] != null) { - data = new List(); + data = []; json['data'].forEach((v) { - data.add(new FavoritesData.fromJson(v)); + data.add(FavoritesData.fromJson(v)); }); } firstPageUrl = json['first_page_url']; @@ -48,24 +48,24 @@ class Data { } class FavoritesData { - int id; - Product product; + int? id; + Product? product; FavoritesData.fromJson(Map json) { id = json['id']; product = - json['product'] != null ? new Product.fromJson(json['product']) : null; + json['product'] != null ? Product.fromJson(json['product']) : null; } } class Product { - int id; + int? id; dynamic price; dynamic oldPrice; - int discount; - String image; - String name; - String description; + int? discount; + String? image; + String? name; + String? description; Product( {this.id, @@ -87,14 +87,14 @@ class Product { } Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['price'] = this.price; - data['old_price'] = this.oldPrice; - data['discount'] = this.discount; - data['image'] = this.image; - data['name'] = this.name; - data['description'] = this.description; + final Map data = {}; + data['id'] = id; + data['price'] = price; + data['old_price'] = oldPrice; + data['discount'] = discount; + data['image'] = image; + data['name'] = name; + data['description'] = description; return data; } } \ No newline at end of file diff --git a/lib/models/shop_app/home_model.dart b/lib/models/shop_app/home_model.dart index c342648..1d5e5c3 100644 --- a/lib/models/shop_app/home_model.dart +++ b/lib/models/shop_app/home_model.dart @@ -1,7 +1,7 @@ class HomeModel { - bool status; - HomeDataModel data; + bool? status; + late HomeDataModel data; HomeModel.fromJson(Map json) { @@ -31,8 +31,8 @@ class HomeDataModel class BannerModel { - int id; - String image; + int? id; + String? image; BannerModel.fromJson(Map json) { @@ -43,14 +43,14 @@ class BannerModel class ProductModel { - int id; + int? id; dynamic price; dynamic oldPrice; dynamic discount; - String image; - String name; - bool inFavorites; - bool inCart; + String? image; + String? name; + bool? inFavorites; + bool? inCart; ProductModel.fromJson(Map json) { diff --git a/lib/models/shop_app/login_model.dart b/lib/models/shop_app/login_model.dart index 0c7b8a8..2ad0493 100644 --- a/lib/models/shop_app/login_model.dart +++ b/lib/models/shop_app/login_model.dart @@ -1,8 +1,8 @@ class ShopLoginModel { - bool status; - String message; - UserData data; + bool? status; + String? message; + UserData? data; ShopLoginModel.fromJson(Map json) { @@ -14,14 +14,14 @@ class ShopLoginModel class UserData { - int id; - String name; - String email; - String phone; - String image; - int points; - int credit; - String token; + int? id; + String? name; + String? email; + String? phone; + String? image; + int? points; + int? credit; + String? token; // UserData({ // this.id, diff --git a/lib/models/shop_app/search_model.dart b/lib/models/shop_app/search_model.dart index 31d8ae3..b0466e3 100644 --- a/lib/models/shop_app/search_model.dart +++ b/lib/models/shop_app/search_model.dart @@ -1,37 +1,37 @@ class SearchModel { - bool status; - Null message; - Data data; + bool? status; + String? message; + Data? data; SearchModel.fromJson(Map json) { status = json['status']; message = json['message']; - data = json['data'] != null ? new Data.fromJson(json['data']) : null; + data = json['data'] != null ? Data.fromJson(json['data']) : null; } } class Data { - int currentPage; - List data; - String firstPageUrl; - int from; - int lastPage; - String lastPageUrl; - Null nextPageUrl; - String path; - int perPage; - Null prevPageUrl; - int to; - int total; + int? currentPage; + late List data; + String? firstPageUrl; + int? from; + int? lastPage; + String? lastPageUrl; + String? nextPageUrl; + String? path; + int? perPage; + String? prevPageUrl; + int? to; + int? total; Data.fromJson(Map json) { currentPage = json['current_page']; if (json['data'] != null) { - data = new List(); + data = []; json['data'].forEach((v) { - data.add(new Product.fromJson(v)); + data.add(Product.fromJson(v)); }); } firstPageUrl = json['first_page_url']; @@ -48,13 +48,13 @@ class Data { } class Product { - int id; + int? id; dynamic price; dynamic oldPrice; - int discount; - String image; - String name; - String description; + int? discount; + String? image; + String? name; + String? description; Product( {this.id, @@ -76,14 +76,14 @@ class Product { } Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['price'] = this.price; - data['old_price'] = this.oldPrice; - data['discount'] = this.discount; - data['image'] = this.image; - data['name'] = this.name; - data['description'] = this.description; + final Map data = {}; + data['id'] = id; + data['price'] = price; + data['old_price'] = oldPrice; + data['discount'] = discount; + data['image'] = image; + data['name'] = name; + data['description'] = description; return data; } } \ No newline at end of file diff --git a/lib/models/social_app/message_model.dart b/lib/models/social_app/message_model.dart index 1ce5603..69d9efd 100644 --- a/lib/models/social_app/message_model.dart +++ b/lib/models/social_app/message_model.dart @@ -1,8 +1,8 @@ class MessageModel { - String senderId; - String receiverId; - String dateTime; - String text; + String? senderId; + String? receiverId; + String? dateTime; + String? text; MessageModel({ this.senderId, diff --git a/lib/models/social_app/post_model.dart b/lib/models/social_app/post_model.dart index 325bbde..82f0d49 100644 --- a/lib/models/social_app/post_model.dart +++ b/lib/models/social_app/post_model.dart @@ -1,11 +1,11 @@ class PostModel { - String name; - String uId; - String image; - String dateTime; - String text; - String postImage; + String? name; + String? uId; + String? image; + String? dateTime; + String? text; + String? postImage; PostModel({ this.name, diff --git a/lib/models/social_app/social_user_model.dart b/lib/models/social_app/social_user_model.dart index 0c03100..971d53c 100644 --- a/lib/models/social_app/social_user_model.dart +++ b/lib/models/social_app/social_user_model.dart @@ -1,12 +1,12 @@ class SocialUserModel { - String name; - String email; - String phone; - String uId; - String image; - String cover; - String bio; - bool isEmailVerified; + String? name; + String? email; + String? phone; + String? uId; + String? image; + String? cover; + String? bio; + bool? isEmailVerified; SocialUserModel({ this.email, diff --git a/lib/models/user/user_model.dart b/lib/models/user/user_model.dart index 4db7798..049e001 100644 --- a/lib/models/user/user_model.dart +++ b/lib/models/user/user_model.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; class UserModel { final int id; @@ -6,8 +5,8 @@ class UserModel { final String phone; UserModel({ - @required this.id, - @required this.phone, - @required this.name, + required this.id, + required this.phone, + required this.name, }); } \ No newline at end of file diff --git a/lib/modules/basics_app/home/home_screen.dart b/lib/modules/basics_app/home/home_screen.dart index 7fa49eb..82dcc9f 100644 --- a/lib/modules/basics_app/home/home_screen.dart +++ b/lib/modules/basics_app/home/home_screen.dart @@ -1,8 +1,9 @@ -import 'dart:ui'; import 'package:flutter/material.dart'; class HomeScreen extends StatelessWidget { + const HomeScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { // main axis alignment : start @@ -11,25 +12,25 @@ class HomeScreen extends StatelessWidget { return Scaffold( appBar: AppBar( backgroundColor: Colors.teal, - leading: Icon( + leading: const Icon( Icons.menu, ), - title: Text( + title: const Text( 'First App', ), actions: [ IconButton( - icon: Icon( + icon: const Icon( Icons.notification_important, ), onPressed: onNotification, ), IconButton( - icon: Text( + icon: const Text( 'hello', ), onPressed: () { - print('hello'); + debugPrint('hello'); }, ), ], @@ -39,7 +40,7 @@ class HomeScreen extends StatelessWidget { Padding( padding: const EdgeInsets.all(50.0), child: Container( - decoration: BoxDecoration( + decoration: const BoxDecoration( borderRadius: BorderRadiusDirectional.only( topStart: Radius.circular( 20.0, @@ -50,7 +51,7 @@ class HomeScreen extends StatelessWidget { child: Stack( alignment: Alignment.bottomCenter, children: [ - Image( + const Image( image: NetworkImage( 'https://cdn.pixabay.com/photo/2015/04/19/08/33/flower-729512__340.jpg', ), @@ -64,7 +65,7 @@ class HomeScreen extends StatelessWidget { padding: const EdgeInsets.symmetric( vertical: 10.0, ), - child: Text( + child: const Text( 'Flower', textAlign: TextAlign.center, style: TextStyle( @@ -84,6 +85,6 @@ class HomeScreen extends StatelessWidget { // when notification icon button clicked void onNotification() { - print('notification clicked'); + debugPrint('notification clicked'); } } diff --git a/lib/modules/basics_app/login/login_screen.dart b/lib/modules/basics_app/login/login_screen.dart index 0bb9ae8..b21dce2 100644 --- a/lib/modules/basics_app/login/login_screen.dart +++ b/lib/modules/basics_app/login/login_screen.dart @@ -8,22 +8,21 @@ import 'package:udemy_flutter/shared/components/components.dart'; // 3. quality // 4. clean code -class LoginScreen extends StatefulWidget -{ +class LoginScreen extends StatefulWidget { + const LoginScreen({Key? key}) : super(key: key); + @override - _LoginScreenState createState() => _LoginScreenState(); + State createState() => _LoginScreenState(); } -class _LoginScreenState extends State -{ +class _LoginScreenState extends State { var emailController = TextEditingController(); var passwordController = TextEditingController(); var formKey = GlobalKey(); bool isPassword = true; @override - Widget build(BuildContext context) - { + Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: Padding( @@ -34,16 +33,15 @@ class _LoginScreenState extends State key: formKey, child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: - [ - Text( + children: [ + const Text( 'Login', style: TextStyle( fontSize: 40.0, fontWeight: FontWeight.bold, ), ), - SizedBox( + const SizedBox( height: 40.0, ), defaultFormField( @@ -51,80 +49,72 @@ class _LoginScreenState extends State label: 'Email', prefix: Icons.email, type: TextInputType.emailAddress, - validate: (String value) - { - if(value.isEmpty) - { + validate: (String value) { + if (value.isEmpty) { return 'email must not be empty'; } return null; }, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( controller: passwordController, label: 'Password', prefix: Icons.lock, - suffix: isPassword ? Icons.visibility : Icons.visibility_off, + suffix: + isPassword ? Icons.visibility : Icons.visibility_off, isPassword: isPassword, - suffixPressed: () - { - setState(() - { + suffixPressed: () { + setState(() { isPassword = !isPassword; }); }, type: TextInputType.visiblePassword, - validate: (String value) - { - if(value.isEmpty) - { + validate: (String value) { + if (value.isEmpty) { return 'password is too short'; } return null; }, ), - SizedBox( + const SizedBox( height: 20.0, ), defaultButton( text: 'login', - function: () - { - if(formKey.currentState.validate()) - { - print(emailController.text); - print(passwordController.text); + function: () { + if (formKey.currentState!.validate()) { + debugPrint(emailController.text); + debugPrint(passwordController.text); } }, ), - SizedBox( + const SizedBox( height: 20.0, ), defaultButton( text: 'ReGIster', - function: () - { - print(emailController.text); - print(passwordController.text); + function: () { + debugPrint(emailController.text); + debugPrint(passwordController.text); }, ), - SizedBox( + const SizedBox( height: 10.0, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( + const Text( 'Don\'t have an account?', ), TextButton( onPressed: () {}, - child: Text( + child: const Text( 'Register Now', ), ), @@ -138,4 +128,4 @@ class _LoginScreenState extends State ), ); } -} \ No newline at end of file +} diff --git a/lib/modules/basics_app/messenger/messenger_screen.dart b/lib/modules/basics_app/messenger/messenger_screen.dart index e731e43..243e752 100644 --- a/lib/modules/basics_app/messenger/messenger_screen.dart +++ b/lib/modules/basics_app/messenger/messenger_screen.dart @@ -1,9 +1,10 @@ -import 'dart:ui'; import 'package:flutter/material.dart'; class MessengerScreen extends StatelessWidget { + const MessengerScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { @@ -14,7 +15,7 @@ class MessengerScreen extends StatelessWidget elevation: 0.0, titleSpacing: 20.0, title: Row( - children: [ + children: const [ CircleAvatar( radius: 20.0, backgroundImage: NetworkImage( @@ -33,7 +34,7 @@ class MessengerScreen extends StatelessWidget ), actions: [ IconButton( - icon: CircleAvatar( + icon: const CircleAvatar( radius: 15.0, backgroundColor: Colors.blue, child: Icon( @@ -45,7 +46,7 @@ class MessengerScreen extends StatelessWidget onPressed: () {}, ), IconButton( - icon: CircleAvatar( + icon: const CircleAvatar( radius: 15.0, backgroundColor: Colors.blue, child: Icon( @@ -71,11 +72,11 @@ class MessengerScreen extends StatelessWidget ), color: Colors.grey[300], ), - padding: EdgeInsets.all( + padding: const EdgeInsets.all( 5.0, ), child: Row( - children: [ + children: const [ Icon( Icons.search, ), @@ -88,28 +89,28 @@ class MessengerScreen extends StatelessWidget ], ), ), - SizedBox( + const SizedBox( height: 20.0, ), - Container( + SizedBox( height: 100.0, child: ListView.separated( scrollDirection: Axis.horizontal, itemBuilder: (context, index) => buildStoryItem(), - separatorBuilder: (context, index) => SizedBox( + separatorBuilder: (context, index) => const SizedBox( width: 20.0, ), itemCount: 5, ), ), - SizedBox( + const SizedBox( height: 20.0, ), ListView.separated( - physics: NeverScrollableScrollPhysics(), + physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) => buildChatItem(), - separatorBuilder: (context, index) => SizedBox( + separatorBuilder: (context, index) => const SizedBox( height: 20.0, ), itemCount: 15, @@ -132,14 +133,14 @@ class MessengerScreen extends StatelessWidget children: [ Stack( alignment: AlignmentDirectional.bottomEnd, - children: [ + children: const [ CircleAvatar( radius: 30.0, backgroundImage: NetworkImage( 'https://avatars.githubusercontent.com/u/34492145?v=4'), ), Padding( - padding: const EdgeInsetsDirectional.only( + padding: EdgeInsetsDirectional.only( bottom: 3.0, end: 3.0, ), @@ -150,14 +151,14 @@ class MessengerScreen extends StatelessWidget ), ], ), - SizedBox( + const SizedBox( width: 20.0, ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( + const Text( 'Abdullah Ahmed Abdullah Ahmed Abdullah Ahmed Abdullah Ahmed', style: TextStyle( fontSize: 16.0, @@ -166,13 +167,13 @@ class MessengerScreen extends StatelessWidget maxLines: 1, overflow: TextOverflow.ellipsis, ), - SizedBox( + const SizedBox( height: 5.0, ), Row( children: [ - Expanded( + const Expanded( child: Text( 'hello my name is abdullah ahmed hello my name is abdullah ahmed', maxLines: 1, @@ -186,13 +187,13 @@ class MessengerScreen extends StatelessWidget child: Container( width: 7.0, height: 7.0, - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Colors.blue, shape: BoxShape.circle, ), ), ), - Text( + const Text( '02:00 pm', ), ], @@ -204,20 +205,20 @@ class MessengerScreen extends StatelessWidget ); Widget buildStoryItem() => - Container( + SizedBox( width: 60.0, child: Column( children: [ Stack( alignment: AlignmentDirectional.bottomEnd, - children: [ + children: const [ CircleAvatar( radius: 30.0, backgroundImage: NetworkImage( 'https://avatars.githubusercontent.com/u/34492145?v=4'), ), Padding( - padding: const EdgeInsetsDirectional.only( + padding: EdgeInsetsDirectional.only( bottom: 3.0, end: 3.0, ), @@ -228,10 +229,10 @@ class MessengerScreen extends StatelessWidget ), ], ), - SizedBox( + const SizedBox( height: 6.0, ), - Text( + const Text( 'Abdullah Mansour Ali Mansour', maxLines: 2, overflow: TextOverflow.ellipsis, diff --git a/lib/modules/basics_app/users/users_screen.dart b/lib/modules/basics_app/users/users_screen.dart index ec7ee9d..cf5be22 100644 --- a/lib/modules/basics_app/users/users_screen.dart +++ b/lib/modules/basics_app/users/users_screen.dart @@ -2,74 +2,75 @@ import 'package:flutter/material.dart'; import 'package:udemy_flutter/models/user/user_model.dart'; class UsersScreen extends StatelessWidget { - List users = [ - UserModel( - id: 1, - name: 'Abdullah Mansour', - phone: '+201115342559', - ), - UserModel( - id: 2, - name: 'Osama Mansour', - phone: '+201117842559', - ), - UserModel( - id: 3, - name: 'Ahmed Ali', - phone: '+2087856136', - ), - UserModel( - id: 1, - name: 'Abdullah Mansour', - phone: '+201115342559', - ), - UserModel( - id: 2, - name: 'Osama Mansour', - phone: '+201117842559', - ), - UserModel( - id: 3, - name: 'Ahmed Ali', - phone: '+2087856136', - ), - UserModel( - id: 1, - name: 'Abdullah Mansour', - phone: '+201115342559', - ), - UserModel( - id: 2, - name: 'Osama Mansour', - phone: '+201117842559', - ), - UserModel( - id: 3, - name: 'Ahmed Ali', - phone: '+2087856136', - ), - UserModel( - id: 1, - name: 'Abdullah Mansour', - phone: '+201115342559', - ), - UserModel( - id: 2, - name: 'Osama Mansour', - phone: '+201117842559', - ), - UserModel( - id: 3, - name: 'Ahmed Ali', - phone: '+2087856136', - ), - ]; + const UsersScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { + List users = [ + UserModel( + id: 1, + name: 'Abdullah Mansour', + phone: '+201115342559', + ), + UserModel( + id: 2, + name: 'Osama Mansour', + phone: '+201117842559', + ), + UserModel( + id: 3, + name: 'Ahmed Ali', + phone: '+2087856136', + ), + UserModel( + id: 1, + name: 'Abdullah Mansour', + phone: '+201115342559', + ), + UserModel( + id: 2, + name: 'Osama Mansour', + phone: '+201117842559', + ), + UserModel( + id: 3, + name: 'Ahmed Ali', + phone: '+2087856136', + ), + UserModel( + id: 1, + name: 'Abdullah Mansour', + phone: '+201115342559', + ), + UserModel( + id: 2, + name: 'Osama Mansour', + phone: '+201117842559', + ), + UserModel( + id: 3, + name: 'Ahmed Ali', + phone: '+2087856136', + ), + UserModel( + id: 1, + name: 'Abdullah Mansour', + phone: '+201115342559', + ), + UserModel( + id: 2, + name: 'Osama Mansour', + phone: '+201117842559', + ), + UserModel( + id: 3, + name: 'Ahmed Ali', + phone: '+2087856136', + ), + ]; return Scaffold( appBar: AppBar( - title: Text( + title: const Text( 'Users', ), ), @@ -98,13 +99,13 @@ class UsersScreen extends StatelessWidget { radius: 25.0, child: Text( '${user.id}', - style: TextStyle( + style: const TextStyle( fontSize: 25.0, fontWeight: FontWeight.bold, ), ), ), - SizedBox( + const SizedBox( width: 20.0, ), Column( @@ -112,15 +113,15 @@ class UsersScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - '${user.name}', - style: TextStyle( + user.name, + style: const TextStyle( fontSize: 25.0, fontWeight: FontWeight.bold, ), ), Text( - '${user.phone}', - style: TextStyle( + user.phone, + style: const TextStyle( color: Colors.grey, ), ), @@ -133,4 +134,4 @@ class UsersScreen extends StatelessWidget { // 1. build item // 2. build list // 3. add item to list -} \ No newline at end of file +} diff --git a/lib/modules/bmi_app/bmi/bmi_screen.dart b/lib/modules/bmi_app/bmi/bmi_screen.dart index 5d8bbf9..e30763a 100644 --- a/lib/modules/bmi_app/bmi/bmi_screen.dart +++ b/lib/modules/bmi_app/bmi/bmi_screen.dart @@ -4,8 +4,10 @@ import 'package:flutter/material.dart'; import 'package:udemy_flutter/modules/bmi_app/bmi_result/bmi_result_screen.dart'; class BmiScreen extends StatefulWidget { + const BmiScreen({Key? key}) : super(key: key); + @override - _BmiScreenState createState() => _BmiScreenState(); + State createState() => _BmiScreenState(); } class _BmiScreenState extends State { @@ -19,13 +21,12 @@ class _BmiScreenState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text( + title: const Text( 'BMI Calculator', ), ), body: Column( - children: - [ + children: [ Expanded( child: Padding( padding: const EdgeInsets.all(20.0), @@ -39,9 +40,15 @@ class _BmiScreenState extends State { }); }, child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular( + 10.0, + ), + color: isMale ? Colors.blue : Colors.grey[400], + ), child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ Image( image: AssetImage('assets/images/male.png'), height: 90.0, @@ -59,16 +66,10 @@ class _BmiScreenState extends State { ), ], ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular( - 10.0, - ), - color: isMale ? Colors.blue : Colors.grey[400], - ), ), ), ), - SizedBox( + const SizedBox( width: 20.0, ), Expanded( @@ -79,9 +80,15 @@ class _BmiScreenState extends State { }); }, child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular( + 10.0, + ), + color: isMale ? Colors.grey[400] : Colors.blue, + ), child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ Image( image: AssetImage('assets/images/female.png'), height: 90.0, @@ -99,12 +106,6 @@ class _BmiScreenState extends State { ), ], ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular( - 10.0, - ), - color: isMale ? Colors.grey[400] : Colors.blue, - ), ), ), ), @@ -118,10 +119,16 @@ class _BmiScreenState extends State { horizontal: 20.0, ), child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular( + 10.0, + ), + color: Colors.grey[400], + ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( + const Text( 'HEIGHT', style: TextStyle( fontSize: 25.0, @@ -135,15 +142,15 @@ class _BmiScreenState extends State { children: [ Text( '${height.round()}', - style: TextStyle( + style: const TextStyle( fontSize: 40.0, fontWeight: FontWeight.w900, ), ), - SizedBox( + const SizedBox( width: 5.0, ), - Text( + const Text( 'CM', style: TextStyle( fontSize: 20.0, @@ -164,12 +171,6 @@ class _BmiScreenState extends State { ), ], ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular( - 10.0, - ), - color: Colors.grey[400], - ), ), ), ), @@ -177,14 +178,19 @@ class _BmiScreenState extends State { child: Padding( padding: const EdgeInsets.all(20.0), child: Row( - children: - [ + children: [ Expanded( child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular( + 10.0, + ), + color: Colors.grey[400], + ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( + const Text( 'WEIGHT', style: TextStyle( fontSize: 25.0, @@ -193,7 +199,7 @@ class _BmiScreenState extends State { ), Text( '$weight', - style: TextStyle( + style: const TextStyle( fontSize: 40.0, fontWeight: FontWeight.w900, ), @@ -209,7 +215,7 @@ class _BmiScreenState extends State { }, heroTag: 'weight-', mini: true, - child: Icon( + child: const Icon( Icons.remove, ), ), @@ -221,7 +227,7 @@ class _BmiScreenState extends State { }, heroTag: 'weight+', mini: true, - child: Icon( + child: const Icon( Icons.add, ), ), @@ -229,23 +235,23 @@ class _BmiScreenState extends State { ), ], ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular( - 10.0, - ), - color: Colors.grey[400], - ), ), ), - SizedBox( + const SizedBox( width: 20.0, ), Expanded( child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular( + 10.0, + ), + color: Colors.grey[400], + ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( + const Text( 'AGE', style: TextStyle( fontSize: 25.0, @@ -254,7 +260,7 @@ class _BmiScreenState extends State { ), Text( '$age', - style: TextStyle( + style: const TextStyle( fontSize: 40.0, fontWeight: FontWeight.w900, ), @@ -270,7 +276,7 @@ class _BmiScreenState extends State { }, heroTag: 'age-', mini: true, - child: Icon( + child: const Icon( Icons.remove, ), ), @@ -282,7 +288,7 @@ class _BmiScreenState extends State { }, heroTag: 'age+', mini: true, - child: Icon( + child: const Icon( Icons.add, ), ), @@ -290,12 +296,6 @@ class _BmiScreenState extends State { ), ], ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular( - 10.0, - ), - color: Colors.grey[400], - ), ), ), ], @@ -308,7 +308,7 @@ class _BmiScreenState extends State { child: MaterialButton( onPressed: () { double result = weight / pow(height / 100, 2); - print(result.round()); + debugPrint(result.round().toString()); Navigator.push( context, @@ -322,7 +322,7 @@ class _BmiScreenState extends State { ); }, height: 50.0, - child: Text( + child: const Text( 'CALCULATE', style: TextStyle( color: Colors.white, @@ -336,5 +336,5 @@ class _BmiScreenState extends State { } // var result = weight / pow(height / 100, 2); -// print(result.round()); -} \ No newline at end of file +// debugPrint(result.round()); +} diff --git a/lib/modules/bmi_app/bmi_result/bmi_result_screen.dart b/lib/modules/bmi_app/bmi_result/bmi_result_screen.dart index 2760678..15da841 100644 --- a/lib/modules/bmi_app/bmi_result/bmi_result_screen.dart +++ b/lib/modules/bmi_app/bmi_result/bmi_result_screen.dart @@ -6,11 +6,11 @@ class BMIResultScreen extends StatelessWidget final bool isMale; final int age; - BMIResultScreen({ - @required this.result, - @required this.age, - @required this.isMale, - }); + const BMIResultScreen({Key? key, + required this.result, + required this.age, + required this.isMale, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -21,11 +21,11 @@ class BMIResultScreen extends StatelessWidget { Navigator.pop(context); }, - icon: Icon( + icon: const Icon( Icons.keyboard_arrow_left, ), ), - title: Text( + title: const Text( 'BMI Result', ), ), @@ -35,21 +35,21 @@ class BMIResultScreen extends StatelessWidget children: [ Text( 'Gender : ${isMale ? 'Male' : 'Female'}', - style: TextStyle( + style: const TextStyle( fontSize: 25.0, fontWeight: FontWeight.bold, ), ), Text( 'Result : $result', - style: TextStyle( + style: const TextStyle( fontSize: 25.0, fontWeight: FontWeight.bold, ), ), Text( 'Age : $age', - style: TextStyle( + style: const TextStyle( fontSize: 25.0, fontWeight: FontWeight.bold, ), diff --git a/lib/modules/counter_app/counter/counter_screen.dart b/lib/modules/counter_app/counter/counter_screen.dart index 287be5a..be2a0a1 100644 --- a/lib/modules/counter_app/counter/counter_screen.dart +++ b/lib/modules/counter_app/counter/counter_screen.dart @@ -12,6 +12,8 @@ import 'package:udemy_flutter/modules/counter_app/counter/cubit/states.dart'; class CounterScreen extends StatelessWidget { + const CounterScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { @@ -22,19 +24,19 @@ class CounterScreen extends StatelessWidget { if(state is CounterMinusState) { - print('minus state ${state.counter}'); + debugPrint('minus state ${state.counter}'); } if(state is CounterPlusState) { - print('plus state ${state.counter}'); + debugPrint('plus state ${state.counter}'); } }, builder: (BuildContext context, CounterStates state) { return Scaffold( appBar: AppBar( - title: Text( + title: const Text( 'Counter', ), ), @@ -47,7 +49,7 @@ class CounterScreen extends StatelessWidget { CounterCubit.get(context).minus(); }, - child: Text( + child: const Text( 'MINUS', ), ), @@ -57,7 +59,7 @@ class CounterScreen extends StatelessWidget ), child: Text( '${CounterCubit.get(context).counter}', - style: TextStyle( + style: const TextStyle( fontSize: 50.0, fontWeight: FontWeight.w900, ), @@ -68,7 +70,7 @@ class CounterScreen extends StatelessWidget { CounterCubit.get(context).plus(); }, - child: Text( + child: const Text( 'PLUS', ), ), diff --git a/lib/modules/counter_app/counter/cubit/cubit.dart b/lib/modules/counter_app/counter/cubit/cubit.dart index 14a6489..3812321 100644 --- a/lib/modules/counter_app/counter/cubit/cubit.dart +++ b/lib/modules/counter_app/counter/cubit/cubit.dart @@ -1,4 +1,3 @@ -import 'package:bloc/bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/modules/counter_app/counter/cubit/states.dart'; diff --git a/lib/modules/news_app/business/business_screen.dart b/lib/modules/news_app/business/business_screen.dart index b094ece..7530a8e 100644 --- a/lib/modules/news_app/business/business_screen.dart +++ b/lib/modules/news_app/business/business_screen.dart @@ -1,19 +1,19 @@ -import 'package:conditional_builder/conditional_builder.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/news_app/cubit/cubit.dart'; import 'package:udemy_flutter/layout/news_app/cubit/states.dart'; import 'package:udemy_flutter/shared/components/components.dart'; -import 'package:udemy_flutter/shared/cubit/cubit.dart'; class BusinessScreen extends StatelessWidget { + const BusinessScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BlocConsumer( listener: (context, state) {}, builder: (context, state) { - var list = NewsCubit.get(context).business; + var list = NewsCubit.get(context).business!; return articleBuilder(list, context); }, diff --git a/lib/modules/news_app/science/science_screen.dart b/lib/modules/news_app/science/science_screen.dart index e54d318..95a014d 100644 --- a/lib/modules/news_app/science/science_screen.dart +++ b/lib/modules/news_app/science/science_screen.dart @@ -1,4 +1,3 @@ -import 'package:conditional_builder/conditional_builder.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/news_app/cubit/cubit.dart'; @@ -6,13 +5,15 @@ import 'package:udemy_flutter/layout/news_app/cubit/states.dart'; import 'package:udemy_flutter/shared/components/components.dart'; class ScienceScreen extends StatelessWidget { + const ScienceScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BlocConsumer( listener: (context, state) {}, builder: (context, state) { - var list = NewsCubit.get(context).science; + var list = NewsCubit.get(context).science!; return articleBuilder(list, context); }, diff --git a/lib/modules/news_app/search/search_screen.dart b/lib/modules/news_app/search/search_screen.dart index 52e0520..d19809d 100644 --- a/lib/modules/news_app/search/search_screen.dart +++ b/lib/modules/news_app/search/search_screen.dart @@ -5,14 +5,16 @@ import 'package:udemy_flutter/layout/news_app/cubit/states.dart'; import 'package:udemy_flutter/shared/components/components.dart'; class SearchScreen extends StatelessWidget { - var searchController = TextEditingController(); + const SearchScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { + var searchController = TextEditingController(); + return BlocConsumer( listener: (context, state) {}, builder: (context, state) { - var list = NewsCubit.get(context).search; + var list = NewsCubit.get(context).search!; return Scaffold( appBar: AppBar(), diff --git a/lib/modules/news_app/sports/sports_screen.dart b/lib/modules/news_app/sports/sports_screen.dart index 4f83727..67f17e4 100644 --- a/lib/modules/news_app/sports/sports_screen.dart +++ b/lib/modules/news_app/sports/sports_screen.dart @@ -1,4 +1,3 @@ -import 'package:conditional_builder/conditional_builder.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/news_app/cubit/cubit.dart'; @@ -7,6 +6,8 @@ import 'package:udemy_flutter/shared/components/components.dart'; class SportsScreen extends StatelessWidget { + const SportsScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { @@ -14,7 +15,7 @@ class SportsScreen extends StatelessWidget listener: (context, state) {}, builder: (context, state) { - var list = NewsCubit.get(context).sports; + var list = NewsCubit.get(context).sports!; return articleBuilder(list, context); }, diff --git a/lib/modules/news_app/web_view/web_view_screen.dart b/lib/modules/news_app/web_view/web_view_screen.dart index 804f27f..436e4d2 100644 --- a/lib/modules/news_app/web_view/web_view_screen.dart +++ b/lib/modules/news_app/web_view/web_view_screen.dart @@ -3,9 +3,9 @@ import 'package:webview_flutter/webview_flutter.dart'; class WebViewScreen extends StatelessWidget { - final String url; + final String? url; - WebViewScreen(this.url); + const WebViewScreen(this.url, {Key? key}) : super(key: key); @override Widget build(BuildContext context) diff --git a/lib/modules/shop_app/cateogries/categories_screen.dart b/lib/modules/shop_app/cateogries/categories_screen.dart index 78deca9..ef88b65 100644 --- a/lib/modules/shop_app/cateogries/categories_screen.dart +++ b/lib/modules/shop_app/cateogries/categories_screen.dart @@ -7,6 +7,8 @@ import 'package:udemy_flutter/shared/components/components.dart'; class CategoriesScreen extends StatelessWidget { + const CategoriesScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { @@ -15,9 +17,9 @@ class CategoriesScreen extends StatelessWidget builder: (context, state) { return ListView.separated( - itemBuilder: (context, index) => buildCatItem(ShopCubit.get(context).categoriesModel.data.data[index]), + itemBuilder: (context, index) => buildCatItem(ShopCubit.get(context).categoriesModel!.data.data[index]), separatorBuilder: (context, index) => myDivider(), - itemCount: ShopCubit.get(context).categoriesModel.data.data.length, + itemCount: ShopCubit.get(context).categoriesModel!.data.data.length, ); }, ); @@ -29,23 +31,23 @@ class CategoriesScreen extends StatelessWidget children: [ Image( - image: NetworkImage(model.image), + image: NetworkImage(model.image!), width: 80.0, height: 80.0, fit: BoxFit.cover, ), - SizedBox( + const SizedBox( width: 20.0, ), Text( - model.name, - style: TextStyle( + model.name!, + style: const TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, ), ), - Spacer(), - Icon( + const Spacer(), + const Icon( Icons.arrow_forward_ios, ), ], diff --git a/lib/modules/shop_app/favorites/favorites_screen.dart b/lib/modules/shop_app/favorites/favorites_screen.dart index 7703ddc..394e345 100644 --- a/lib/modules/shop_app/favorites/favorites_screen.dart +++ b/lib/modules/shop_app/favorites/favorites_screen.dart @@ -1,14 +1,14 @@ -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/shop_app/cubit/cubit.dart'; import 'package:udemy_flutter/layout/shop_app/cubit/states.dart'; -import 'package:udemy_flutter/models/shop_app/favorites_model.dart'; import 'package:udemy_flutter/shared/components/components.dart'; -import 'package:udemy_flutter/shared/styles/colors.dart'; class FavoritesScreen extends StatelessWidget { + const FavoritesScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { @@ -19,11 +19,11 @@ class FavoritesScreen extends StatelessWidget return ConditionalBuilder( condition: state is! ShopLoadingGetFavoritesState, builder: (context) => ListView.separated( - itemBuilder: (context, index) => buildListProduct(ShopCubit.get(context).favoritesModel.data.data[index].product, context), + itemBuilder: (context, index) => buildListProduct(ShopCubit.get(context).favoritesModel.data!.data[index].product, context), separatorBuilder: (context, index) => myDivider(), - itemCount: ShopCubit.get(context).favoritesModel.data.data.length, + itemCount: ShopCubit.get(context).favoritesModel.data!.data.length, ), - fallback: (context) => Center(child: CircularProgressIndicator()), + fallback: (context) => const Center(child: CircularProgressIndicator()), ); }, ); diff --git a/lib/modules/shop_app/login/cubit/cubit.dart b/lib/modules/shop_app/login/cubit/cubit.dart index 2202e3f..2a8a5dc 100644 --- a/lib/modules/shop_app/login/cubit/cubit.dart +++ b/lib/modules/shop_app/login/cubit/cubit.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/models/shop_app/login_model.dart'; @@ -11,17 +10,17 @@ class ShopLoginCubit extends Cubit { static ShopLoginCubit get(context) => BlocProvider.of(context); - ShopLoginModel loginModel; + ShopLoginModel? loginModel; void userLogin({ - @required String email, - @required String password, + required String email, + required String password, }) { emit(ShopLoginLoadingState()); DioHelper.postData( - url: LOGIN, + url: kLOGIN, data: { 'email': email, @@ -29,12 +28,12 @@ class ShopLoginCubit extends Cubit { }, ).then((value) { - print(value.data); + debugPrint(value.data); loginModel = ShopLoginModel.fromJson(value.data); emit(ShopLoginSuccessState(loginModel)); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(ShopLoginErrorState(error.toString())); }); } diff --git a/lib/modules/shop_app/login/cubit/states.dart b/lib/modules/shop_app/login/cubit/states.dart index 5d04c9a..62c3c45 100644 --- a/lib/modules/shop_app/login/cubit/states.dart +++ b/lib/modules/shop_app/login/cubit/states.dart @@ -8,7 +8,7 @@ class ShopLoginLoadingState extends ShopLoginStates {} class ShopLoginSuccessState extends ShopLoginStates { - final ShopLoginModel loginModel; + final ShopLoginModel? loginModel; ShopLoginSuccessState(this.loginModel); } diff --git a/lib/modules/shop_app/login/shop_login_screen.dart b/lib/modules/shop_app/login/shop_login_screen.dart index 2efcab1..08467fb 100644 --- a/lib/modules/shop_app/login/shop_login_screen.dart +++ b/lib/modules/shop_app/login/shop_login_screen.dart @@ -1,7 +1,6 @@ -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:fluttertoast/fluttertoast.dart'; import 'package:udemy_flutter/layout/shop_app/shop_layout.dart'; import 'package:udemy_flutter/modules/shop_app/login/cubit/cubit.dart'; import 'package:udemy_flutter/modules/shop_app/login/cubit/states.dart'; @@ -10,44 +9,42 @@ import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/components/constants.dart'; import 'package:udemy_flutter/shared/network/local/cache_helper.dart'; -class ShopLoginScreen extends StatelessWidget -{ - var formKey = GlobalKey(); - var emailController = TextEditingController(); - var passwordController = TextEditingController(); +class ShopLoginScreen extends StatelessWidget { + const ShopLoginScreen({Key? key}) : super(key: key); + @override - Widget build(BuildContext context) - { + Widget build(BuildContext context) { + var formKey = GlobalKey(); + var emailController = TextEditingController(); + var passwordController = TextEditingController(); + return BlocProvider( create: (BuildContext context) => ShopLoginCubit(), child: BlocConsumer( listener: (context, state) { - if (state is ShopLoginSuccessState) - { - if (state.loginModel.status) - { - print(state.loginModel.message); - print(state.loginModel.data.token); + if (state is ShopLoginSuccessState) { + if (state.loginModel!.status!) { + debugPrint(state.loginModel!.message); + debugPrint(state.loginModel!.data!.token); CacheHelper.saveData( key: 'token', - value: state.loginModel.data.token, - ).then((value) - { - token = state.loginModel.data.token; + value: state.loginModel!.data!.token, + ).then((value) { + token = state.loginModel!.data!.token; navigateAndFinish( context, - ShopLayout(), + const ShopLayout(), ); }); } else { - print(state.loginModel.message); + debugPrint(state.loginModel!.message); showToast( - text: state.loginModel.message, - state: ToastStates.ERROR, + text: state.loginModel!.message!, + state: ToastStates.kERROR, ); } } @@ -66,17 +63,19 @@ class ShopLoginScreen extends StatelessWidget children: [ Text( 'LOGIN', - style: Theme.of(context).textTheme.headline4.copyWith( - color: Colors.black, - ), + style: + Theme.of(context).textTheme.headline4!.copyWith( + color: Colors.black, + ), ), Text( 'Login now to browse our hot offers', - style: Theme.of(context).textTheme.bodyText1.copyWith( - color: Colors.grey, - ), + style: + Theme.of(context).textTheme.bodyText1!.copyWith( + color: Colors.grey, + ), ), - SizedBox( + const SizedBox( height: 30.0, ), defaultFormField( @@ -90,7 +89,7 @@ class ShopLoginScreen extends StatelessWidget label: 'Email Address', prefix: Icons.email_outlined, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( @@ -98,7 +97,7 @@ class ShopLoginScreen extends StatelessWidget type: TextInputType.visiblePassword, suffix: ShopLoginCubit.get(context).suffix, onSubmit: (value) { - if (formKey.currentState.validate()) { + if (formKey.currentState!.validate()) { ShopLoginCubit.get(context).userLogin( email: emailController.text, password: passwordController.text, @@ -118,14 +117,14 @@ class ShopLoginScreen extends StatelessWidget label: 'Password', prefix: Icons.lock_outline, ), - SizedBox( + const SizedBox( height: 30.0, ), ConditionalBuilder( condition: state is! ShopLoginLoadingState, builder: (context) => defaultButton( function: () { - if (formKey.currentState.validate()) { + if (formKey.currentState!.validate()) { ShopLoginCubit.get(context).userLogin( email: emailController.text, password: passwordController.text, @@ -136,22 +135,22 @@ class ShopLoginScreen extends StatelessWidget isUpperCase: true, ), fallback: (context) => - Center(child: CircularProgressIndicator()), + const Center(child: CircularProgressIndicator()), ), - SizedBox( + const SizedBox( height: 15.0, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( + const Text( 'Don\'t have an account?', ), defaultTextButton( function: () { navigateTo( context, - ShopRegisterScreen(), + const ShopRegisterScreen(), ); }, text: 'register', @@ -169,4 +168,4 @@ class ShopLoginScreen extends StatelessWidget ), ); } -} \ No newline at end of file +} diff --git a/lib/modules/shop_app/on_boarding/on_boarding_screen.dart b/lib/modules/shop_app/on_boarding/on_boarding_screen.dart index bee6bcf..b66f85d 100644 --- a/lib/modules/shop_app/on_boarding/on_boarding_screen.dart +++ b/lib/modules/shop_app/on_boarding/on_boarding_screen.dart @@ -11,15 +11,17 @@ class BoardingModel { final String body; BoardingModel({ - @required this.title, - @required this.image, - @required this.body, + required this.title, + required this.image, + required this.body, }); } class OnBoardingScreen extends StatefulWidget { + const OnBoardingScreen({Key? key}) : super(key: key); + @override - _OnBoardingScreenState createState() => _OnBoardingScreenState(); + State createState() => _OnBoardingScreenState(); } class _OnBoardingScreenState extends State { @@ -49,12 +51,11 @@ class _OnBoardingScreenState extends State { CacheHelper.saveData( key: 'onBoarding', value: true, - ).then((value) - { + ).then((value) { if (value) { navigateAndFinish( context, - ShopLoginScreen(), + const ShopLoginScreen(), ); } }); @@ -77,7 +78,7 @@ class _OnBoardingScreenState extends State { children: [ Expanded( child: PageView.builder( - physics: BouncingScrollPhysics(), + physics: const BouncingScrollPhysics(), controller: boardController, onPageChanged: (int index) { if (index == boarding.length - 1) { @@ -95,14 +96,14 @@ class _OnBoardingScreenState extends State { itemCount: boarding.length, ), ), - SizedBox( + const SizedBox( height: 40.0, ), Row( children: [ SmoothPageIndicator( controller: boardController, - effect: ExpandingDotsEffect( + effect: const ExpandingDotsEffect( dotColor: Colors.grey, activeDotColor: defaultColor, dotHeight: 10, @@ -112,22 +113,21 @@ class _OnBoardingScreenState extends State { ), count: boarding.length, ), - Spacer(), + const Spacer(), FloatingActionButton( onPressed: () { - if (isLast) - { + if (isLast) { submit(); } else { boardController.nextPage( - duration: Duration( + duration: const Duration( milliseconds: 750, ), curve: Curves.fastLinearToSlowEaseIn, ); } }, - child: Icon( + child: const Icon( Icons.arrow_forward_ios, ), ), @@ -144,28 +144,28 @@ class _OnBoardingScreenState extends State { children: [ Expanded( child: Image( - image: AssetImage('${model.image}'), + image: AssetImage(model.image), ), ), - SizedBox( + const SizedBox( height: 30.0, ), Text( - '${model.title}', - style: TextStyle( + model.title, + style: const TextStyle( fontSize: 24.0, ), ), - SizedBox( + const SizedBox( height: 15.0, ), Text( - '${model.body}', - style: TextStyle( + model.body, + style: const TextStyle( fontSize: 14.0, ), ), - SizedBox( + const SizedBox( height: 30.0, ), ], diff --git a/lib/modules/shop_app/products/products_screen.dart b/lib/modules/shop_app/products/products_screen.dart index 92d691f..305f084 100644 --- a/lib/modules/shop_app/products/products_screen.dart +++ b/lib/modules/shop_app/products/products_screen.dart @@ -1,5 +1,5 @@ import 'package:carousel_slider/carousel_slider.dart'; -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/shop_app/cubit/cubit.dart'; @@ -10,15 +10,17 @@ import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/styles/colors.dart'; class ProductsScreen extends StatelessWidget { + const ProductsScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BlocConsumer( listener: (context, state) { if (state is ShopSuccessChangeFavoritesState) { - if (!state.model.status) { + if (!state.model!.status!) { showToast( - text: state.model.message, - state: ToastStates.ERROR, + text: state.model!.message!, + state: ToastStates.kERROR, ); } } @@ -27,9 +29,9 @@ class ProductsScreen extends StatelessWidget { return ConditionalBuilder( condition: ShopCubit.get(context).homeModel != null && ShopCubit.get(context).categoriesModel != null, - builder: (context) => builderWidget(ShopCubit.get(context).homeModel, - ShopCubit.get(context).categoriesModel, context), - fallback: (context) => Center( + builder: (context) => builderWidget(ShopCubit.get(context).homeModel!, + ShopCubit.get(context).categoriesModel!, context), + fallback: (context) => const Center( child: CircularProgressIndicator(), ), ); @@ -40,7 +42,7 @@ class ProductsScreen extends StatelessWidget { Widget builderWidget( HomeModel model, CategoriesModel categoriesModel, context) => SingleChildScrollView( - physics: BouncingScrollPhysics(), + physics: const BouncingScrollPhysics(), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -48,7 +50,7 @@ class ProductsScreen extends StatelessWidget { items: model.data.banners .map( (e) => Image( - image: NetworkImage(e.image), + image: NetworkImage(e.image!), fit: BoxFit.cover, width: double.infinity, ), @@ -62,13 +64,13 @@ class ProductsScreen extends StatelessWidget { enableInfiniteScroll: true, reverse: false, autoPlay: true, - autoPlayInterval: Duration(seconds: 3), - autoPlayAnimationDuration: Duration(seconds: 1), + autoPlayInterval: const Duration(seconds: 3), + autoPlayAnimationDuration: const Duration(seconds: 1), autoPlayCurve: Curves.fastOutSlowIn, scrollDirection: Axis.horizontal, ), ), - SizedBox( + const SizedBox( height: 10.0, ), Padding( @@ -78,33 +80,33 @@ class ProductsScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( + const Text( 'Categories', style: TextStyle( fontSize: 24.0, fontWeight: FontWeight.w800, ), ), - SizedBox( + const SizedBox( height: 10.0, ), - Container( + SizedBox( height: 100.0, child: ListView.separated( - physics: BouncingScrollPhysics(), + physics: const BouncingScrollPhysics(), scrollDirection: Axis.horizontal, itemBuilder: (context, index) => buildCategoryItem(categoriesModel.data.data[index]), - separatorBuilder: (context, index) => SizedBox( + separatorBuilder: (context, index) => const SizedBox( width: 10.0, ), itemCount: categoriesModel.data.data.length, ), ), - SizedBox( + const SizedBox( height: 20.0, ), - Text( + const Text( 'New Products', style: TextStyle( fontSize: 24.0, @@ -114,14 +116,14 @@ class ProductsScreen extends StatelessWidget { ], ), ), - SizedBox( + const SizedBox( height: 10.0, ), Container( color: Colors.grey[300], child: GridView.count( shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), + physics: const NeverScrollableScrollPhysics(), crossAxisCount: 2, mainAxisSpacing: 1.0, crossAxisSpacing: 1.0, @@ -141,7 +143,7 @@ class ProductsScreen extends StatelessWidget { alignment: AlignmentDirectional.bottomCenter, children: [ Image( - image: NetworkImage(model.image), + image: NetworkImage(model.image!), height: 100.0, width: 100.0, fit: BoxFit.cover, @@ -152,11 +154,11 @@ class ProductsScreen extends StatelessWidget { ), width: 100.0, child: Text( - model.name, + model.name!, textAlign: TextAlign.center, maxLines: 1, overflow: TextOverflow.ellipsis, - style: TextStyle( + style: const TextStyle( color: Colors.white, ), ), @@ -173,17 +175,17 @@ class ProductsScreen extends StatelessWidget { alignment: AlignmentDirectional.bottomStart, children: [ Image( - image: NetworkImage(model.image), + image: NetworkImage(model.image!), width: double.infinity, height: 200.0, ), if (model.discount != 0) Container( color: Colors.red, - padding: EdgeInsets.symmetric( + padding: const EdgeInsets.symmetric( horizontal: 5.0, ), - child: Text( + child: const Text( 'DISCOUNT', style: TextStyle( fontSize: 8.0, @@ -199,10 +201,10 @@ class ProductsScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - model.name, + model.name!, maxLines: 2, overflow: TextOverflow.ellipsis, - style: TextStyle( + style: const TextStyle( fontSize: 14.0, height: 1.3, ), @@ -211,36 +213,36 @@ class ProductsScreen extends StatelessWidget { children: [ Text( '${model.price.round()}', - style: TextStyle( + style: const TextStyle( fontSize: 12.0, color: defaultColor, ), ), - SizedBox( + const SizedBox( width: 5.0, ), if (model.discount != 0) Text( '${model.oldPrice.round()}', - style: TextStyle( + style: const TextStyle( fontSize: 10.0, color: Colors.grey, decoration: TextDecoration.lineThrough, ), ), - Spacer(), + const Spacer(), IconButton( onPressed: () { ShopCubit.get(context).changeFavorites(model.id); - print(model.id); + debugPrint(model.id.toString()); }, icon: CircleAvatar( radius: 15.0, backgroundColor: - ShopCubit.get(context).favorites[model.id] + ShopCubit.get(context).favorites[model.id]! ? defaultColor : Colors.grey, - child: Icon( + child: const Icon( Icons.favorite_border, size: 14.0, color: Colors.white, diff --git a/lib/modules/shop_app/register/cubit/cubit.dart b/lib/modules/shop_app/register/cubit/cubit.dart index 6fb7115..9ea4a8d 100644 --- a/lib/modules/shop_app/register/cubit/cubit.dart +++ b/lib/modules/shop_app/register/cubit/cubit.dart @@ -1,8 +1,6 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/models/shop_app/login_model.dart'; -import 'package:udemy_flutter/modules/shop_app/login/cubit/states.dart'; import 'package:udemy_flutter/modules/shop_app/register/cubit/states.dart'; import 'package:udemy_flutter/shared/network/end_points.dart'; import 'package:udemy_flutter/shared/network/remote/dio_helper.dart'; @@ -12,19 +10,19 @@ class ShopRegisterCubit extends Cubit { static ShopRegisterCubit get(context) => BlocProvider.of(context); - ShopLoginModel loginModel; + ShopLoginModel? loginModel; void userRegister({ - @required String name, - @required String email, - @required String password, - @required String phone, + required String name, + required String email, + required String password, + required String phone, }) { emit(ShopRegisterLoadingState()); DioHelper.postData( - url: REGISTER, + url: kREGISTER, data: { 'name': name, @@ -34,12 +32,12 @@ class ShopRegisterCubit extends Cubit { }, ).then((value) { - print(value.data); + debugPrint(value.data); loginModel = ShopLoginModel.fromJson(value.data); emit(ShopRegisterSuccessState(loginModel)); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(ShopRegisterErrorState(error.toString())); }); } diff --git a/lib/modules/shop_app/register/cubit/states.dart b/lib/modules/shop_app/register/cubit/states.dart index e20a704..f0cddc8 100644 --- a/lib/modules/shop_app/register/cubit/states.dart +++ b/lib/modules/shop_app/register/cubit/states.dart @@ -8,7 +8,7 @@ class ShopRegisterLoadingState extends ShopRegisterStates {} class ShopRegisterSuccessState extends ShopRegisterStates { - final ShopLoginModel loginModel; + final ShopLoginModel? loginModel; ShopRegisterSuccessState(this.loginModel); } diff --git a/lib/modules/shop_app/register/shop_register_screen.dart b/lib/modules/shop_app/register/shop_register_screen.dart index c39505f..839e671 100644 --- a/lib/modules/shop_app/register/shop_register_screen.dart +++ b/lib/modules/shop_app/register/shop_register_screen.dart @@ -1,61 +1,55 @@ -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/shop_app/shop_layout.dart'; -import 'package:udemy_flutter/modules/shop_app/login/cubit/cubit.dart'; import 'package:udemy_flutter/modules/shop_app/register/cubit/cubit.dart'; import 'package:udemy_flutter/modules/shop_app/register/cubit/states.dart'; import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/components/constants.dart'; import 'package:udemy_flutter/shared/network/local/cache_helper.dart'; -class ShopRegisterScreen extends StatelessWidget -{ - var formKey = GlobalKey(); - var nameController = TextEditingController(); - var emailController = TextEditingController(); - var passwordController = TextEditingController(); - var phoneController = TextEditingController(); +class ShopRegisterScreen extends StatelessWidget { + const ShopRegisterScreen({Key? key}) : super(key: key); @override - Widget build(BuildContext context) - { + Widget build(BuildContext context) { + var formKey = GlobalKey(); + var nameController = TextEditingController(); + var emailController = TextEditingController(); + var passwordController = TextEditingController(); + var phoneController = TextEditingController(); + return BlocProvider( create: (BuildContext context) => ShopRegisterCubit(), child: BlocConsumer( - listener: (context, state) - { - if (state is ShopRegisterSuccessState) - { - if (state.loginModel.status) - { - print(state.loginModel.message); - print(state.loginModel.data.token); + listener: (context, state) { + if (state is ShopRegisterSuccessState) { + if (state.loginModel!.status!) { + debugPrint(state.loginModel!.message); + debugPrint(state.loginModel!.data!.token); CacheHelper.saveData( key: 'token', - value: state.loginModel.data.token, - ).then((value) - { - token = state.loginModel.data.token; + value: state.loginModel!.data!.token, + ).then((value) { + token = state.loginModel!.data!.token; navigateAndFinish( context, - ShopLayout(), + const ShopLayout(), ); }); } else { - print(state.loginModel.message); + debugPrint(state.loginModel!.message); showToast( - text: state.loginModel.message, - state: ToastStates.ERROR, + text: state.loginModel!.message!, + state: ToastStates.kERROR, ); } } }, - builder: (context, state) - { + builder: (context, state) { return Scaffold( appBar: AppBar(), body: Center( @@ -69,17 +63,19 @@ class ShopRegisterScreen extends StatelessWidget children: [ Text( 'REGISTER', - style: Theme.of(context).textTheme.headline4.copyWith( - color: Colors.black, - ), + style: + Theme.of(context).textTheme.headline4!.copyWith( + color: Colors.black, + ), ), Text( 'Register now to browse our hot offers', - style: Theme.of(context).textTheme.bodyText1.copyWith( - color: Colors.grey, - ), + style: + Theme.of(context).textTheme.bodyText1!.copyWith( + color: Colors.grey, + ), ), - SizedBox( + const SizedBox( height: 30.0, ), defaultFormField( @@ -93,7 +89,7 @@ class ShopRegisterScreen extends StatelessWidget label: 'User Name', prefix: Icons.person, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( @@ -107,17 +103,14 @@ class ShopRegisterScreen extends StatelessWidget label: 'Email Address', prefix: Icons.email_outlined, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( controller: passwordController, type: TextInputType.visiblePassword, suffix: ShopRegisterCubit.get(context).suffix, - onSubmit: (value) - { - - }, + onSubmit: (value) {}, isPassword: ShopRegisterCubit.get(context).isPassword, suffixPressed: () { ShopRegisterCubit.get(context) @@ -131,7 +124,7 @@ class ShopRegisterScreen extends StatelessWidget label: 'Password', prefix: Icons.lock_outline, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( @@ -145,15 +138,14 @@ class ShopRegisterScreen extends StatelessWidget label: 'Phone', prefix: Icons.phone, ), - SizedBox( + const SizedBox( height: 30.0, ), ConditionalBuilder( condition: state is! ShopRegisterLoadingState, builder: (context) => defaultButton( function: () { - if (formKey.currentState.validate()) - { + if (formKey.currentState!.validate()) { ShopRegisterCubit.get(context).userRegister( name: nameController.text, email: emailController.text, @@ -166,7 +158,7 @@ class ShopRegisterScreen extends StatelessWidget isUpperCase: true, ), fallback: (context) => - Center(child: CircularProgressIndicator()), + const Center(child: CircularProgressIndicator()), ), ], ), diff --git a/lib/modules/shop_app/search/cubit/cubit.dart b/lib/modules/shop_app/search/cubit/cubit.dart index 45d9a56..6b4f5ef 100644 --- a/lib/modules/shop_app/search/cubit/cubit.dart +++ b/lib/modules/shop_app/search/cubit/cubit.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/models/shop_app/search_model.dart'; import 'package:udemy_flutter/modules/shop_app/search/cubit/states.dart'; @@ -10,13 +11,13 @@ class SearchCubit extends Cubit { static SearchCubit get(context) => BlocProvider.of(context); - SearchModel model; + late SearchModel model; void search(String text) { emit(SearchLoadingState()); DioHelper.postData( - url: SEARCH, + url: kSEARCH, token: token, data: { 'text': text, @@ -28,7 +29,7 @@ class SearchCubit extends Cubit { emit(SearchSuccessState()); }).catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(SearchErrorState()); }); } diff --git a/lib/modules/shop_app/search/search_screen.dart b/lib/modules/shop_app/search/search_screen.dart index ffc0e2f..dcfac37 100644 --- a/lib/modules/shop_app/search/search_screen.dart +++ b/lib/modules/shop_app/search/search_screen.dart @@ -5,6 +5,8 @@ import 'package:udemy_flutter/modules/shop_app/search/cubit/states.dart'; import 'package:udemy_flutter/shared/components/components.dart'; class SearchScreen extends StatelessWidget { + const SearchScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { var formKey = GlobalKey(); @@ -39,24 +41,24 @@ class SearchScreen extends StatelessWidget { label: 'Search', prefix: Icons.search, ), - SizedBox( + const SizedBox( height: 10.0, ), - if (state is SearchLoadingState) LinearProgressIndicator(), - SizedBox( + if (state is SearchLoadingState) const LinearProgressIndicator(), + const SizedBox( height: 10.0, ), if (state is SearchSuccessState) Expanded( child: ListView.separated( itemBuilder: (context, index) => buildListProduct( - SearchCubit.get(context).model.data.data[index], + SearchCubit.get(context).model.data!.data[index], context, isOldPrice: false, ), separatorBuilder: (context, index) => myDivider(), itemCount: - SearchCubit.get(context).model.data.data.length, + SearchCubit.get(context).model.data!.data.length, ), ), ], diff --git a/lib/modules/shop_app/settings/settings_screen.dart b/lib/modules/shop_app/settings/settings_screen.dart index 4dbb7cb..bf8c4d3 100644 --- a/lib/modules/shop_app/settings/settings_screen.dart +++ b/lib/modules/shop_app/settings/settings_screen.dart @@ -1,4 +1,4 @@ -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/shop_app/cubit/cubit.dart'; @@ -7,21 +7,24 @@ import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/components/constants.dart'; class SettingsScreen extends StatelessWidget { - var formKey = GlobalKey(); - var nameController = TextEditingController(); - var emailController = TextEditingController(); - var phoneController = TextEditingController(); + const SettingsScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { + var formKey = GlobalKey(); + var nameController = TextEditingController(); + var emailController = TextEditingController(); + var phoneController = TextEditingController(); + return BlocConsumer( listener: (context, state) {}, builder: (context, state) { - var model = ShopCubit.get(context).userModel; + var model = ShopCubit.get(context).userModel!; - nameController.text = model.data.name; - emailController.text = model.data.email; - phoneController.text = model.data.phone; + nameController.text = model.data!.name!; + emailController.text = model.data!.email!; + phoneController.text = model.data!.phone!; return ConditionalBuilder( condition: ShopCubit.get(context).userModel != null, @@ -33,8 +36,8 @@ class SettingsScreen extends StatelessWidget { children: [ if(state is ShopLoadingUpdateUserState) - LinearProgressIndicator(), - SizedBox( + const LinearProgressIndicator(), + const SizedBox( height: 20.0, ), defaultFormField( @@ -50,7 +53,7 @@ class SettingsScreen extends StatelessWidget { label: 'Name', prefix: Icons.person, ), - SizedBox( + const SizedBox( height: 20.0, ), defaultFormField( @@ -66,7 +69,7 @@ class SettingsScreen extends StatelessWidget { label: 'Email Address', prefix: Icons.email, ), - SizedBox( + const SizedBox( height: 20.0, ), defaultFormField( @@ -82,13 +85,13 @@ class SettingsScreen extends StatelessWidget { label: 'Phone', prefix: Icons.phone, ), - SizedBox( + const SizedBox( height: 20.0, ), defaultButton( function: () { - if(formKey.currentState.validate()) + if(formKey.currentState!.validate()) { ShopCubit.get(context).updateUserData( name: nameController.text, @@ -99,7 +102,7 @@ class SettingsScreen extends StatelessWidget { }, text: 'update', ), - SizedBox( + const SizedBox( height: 20.0, ), defaultButton( @@ -112,7 +115,7 @@ class SettingsScreen extends StatelessWidget { ), ), ), - fallback: (context) => Center(child: CircularProgressIndicator()), + fallback: (context) => const Center(child: CircularProgressIndicator()), ); }, ); diff --git a/lib/modules/social_app/chat_details/chat_details_screen.dart b/lib/modules/social_app/chat_details/chat_details_screen.dart index df987c8..407c217 100644 --- a/lib/modules/social_app/chat_details/chat_details_screen.dart +++ b/lib/modules/social_app/chat_details/chat_details_screen.dart @@ -1,4 +1,4 @@ -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/social_app/cubit/cubit.dart'; @@ -9,20 +9,18 @@ import 'package:udemy_flutter/shared/styles/colors.dart'; import 'package:udemy_flutter/shared/styles/icon_broken.dart'; class ChatDetailsScreen extends StatelessWidget { - SocialUserModel userModel; + final SocialUserModel? userModel; - ChatDetailsScreen({ - this.userModel, - }); - - var messageController = TextEditingController(); + const ChatDetailsScreen({Key? key, this.userModel}) : super(key: key); @override Widget build(BuildContext context) { + var messageController = TextEditingController(); + return Builder( builder: (BuildContext context) { SocialCubit.get(context).getMessages( - receiverId: userModel.uId, + receiverId: userModel!.uId, ); return BlocConsumer( @@ -36,37 +34,39 @@ class ChatDetailsScreen extends StatelessWidget { CircleAvatar( radius: 20.0, backgroundImage: NetworkImage( - userModel.image, + userModel!.image!, ), ), - SizedBox( + const SizedBox( width: 15.0, ), Text( - userModel.name, + userModel!.name!, ), ], ), ), body: ConditionalBuilder( - condition: SocialCubit.get(context).messages.length > 0, + condition: SocialCubit.get(context).messages.isNotEmpty, builder: (context) => Padding( padding: const EdgeInsets.all(20.0), child: Column( children: [ Expanded( child: ListView.separated( - physics: BouncingScrollPhysics(), - itemBuilder: (context, index) - { - var message = SocialCubit.get(context).messages[index]; + physics: const BouncingScrollPhysics(), + itemBuilder: (context, index) { + var message = + SocialCubit.get(context).messages[index]; - if(SocialCubit.get(context).userModel.uId == message.senderId) + if (SocialCubit.get(context).userModel!.uId == + message.senderId) { return buildMyMessage(message); + } return buildMessage(message); }, - separatorBuilder: (context, index) => SizedBox( + separatorBuilder: (context, index) => const SizedBox( height: 15.0, ), itemCount: SocialCubit.get(context).messages.length, @@ -75,7 +75,7 @@ class ChatDetailsScreen extends StatelessWidget { Container( decoration: BoxDecoration( border: Border.all( - color: Colors.grey[300], + color: Colors.grey[300]!, width: 1.0, ), borderRadius: BorderRadius.circular( @@ -92,7 +92,7 @@ class ChatDetailsScreen extends StatelessWidget { ), child: TextFormField( controller: messageController, - decoration: InputDecoration( + decoration: const InputDecoration( border: InputBorder.none, hintText: 'type your message here ...', ), @@ -105,14 +105,14 @@ class ChatDetailsScreen extends StatelessWidget { child: MaterialButton( onPressed: () { SocialCubit.get(context).sendMessage( - receiverId: userModel.uId, + receiverId: userModel!.uId, dateTime: DateTime.now().toString(), text: messageController.text, ); }, minWidth: 1.0, - child: Icon( - IconBroken.Send, + child: const Icon( + IconBroken.kSend, size: 16.0, color: Colors.white, ), @@ -124,7 +124,7 @@ class ChatDetailsScreen extends StatelessWidget { ], ), ), - fallback: (context) => Center( + fallback: (context) => const Center( child: CircularProgressIndicator(), ), ), @@ -140,7 +140,7 @@ class ChatDetailsScreen extends StatelessWidget { child: Container( decoration: BoxDecoration( color: Colors.grey[300], - borderRadius: BorderRadiusDirectional.only( + borderRadius: const BorderRadiusDirectional.only( bottomEnd: Radius.circular( 10.0, ), @@ -152,12 +152,12 @@ class ChatDetailsScreen extends StatelessWidget { ), ), ), - padding: EdgeInsets.symmetric( + padding: const EdgeInsets.symmetric( vertical: 5.0, horizontal: 10.0, ), child: Text( - model.text, + model.text!, ), ), ); @@ -169,7 +169,7 @@ class ChatDetailsScreen extends StatelessWidget { color: defaultColor.withOpacity( .2, ), - borderRadius: BorderRadiusDirectional.only( + borderRadius: const BorderRadiusDirectional.only( bottomStart: Radius.circular( 10.0, ), @@ -181,12 +181,12 @@ class ChatDetailsScreen extends StatelessWidget { ), ), ), - padding: EdgeInsets.symmetric( + padding: const EdgeInsets.symmetric( vertical: 5.0, horizontal: 10.0, ), child: Text( - model.text, + model.text!, ), ), ); diff --git a/lib/modules/social_app/chats/chats_screen.dart b/lib/modules/social_app/chats/chats_screen.dart index 1b2d5b6..55ba22e 100644 --- a/lib/modules/social_app/chats/chats_screen.dart +++ b/lib/modules/social_app/chats/chats_screen.dart @@ -1,4 +1,4 @@ -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/social_app/cubit/cubit.dart'; @@ -8,21 +8,23 @@ import 'package:udemy_flutter/modules/social_app/chat_details/chat_details_scree import 'package:udemy_flutter/shared/components/components.dart'; class ChatsScreen extends StatelessWidget { + const ChatsScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BlocConsumer( listener: (context, state) {}, builder: (context, state) { return ConditionalBuilder( - condition: SocialCubit.get(context).users.length > 0, + condition: SocialCubit.get(context).users.isNotEmpty, builder: (context) => ListView.separated( - physics: BouncingScrollPhysics(), + physics: const BouncingScrollPhysics(), itemBuilder: (context, index) => buildChatItem(SocialCubit.get(context).users[index], context), separatorBuilder: (context, index) => myDivider(), itemCount: SocialCubit.get(context).users.length, ), - fallback: (context) => Center(child: CircularProgressIndicator()), + fallback: (context) => const Center(child: CircularProgressIndicator()), ); }, ); @@ -47,12 +49,12 @@ class ChatsScreen extends StatelessWidget { '${model.image}', ), ), - SizedBox( + const SizedBox( width: 15.0, ), Text( '${model.name}', - style: TextStyle( + style: const TextStyle( height: 1.4, ), ), diff --git a/lib/modules/social_app/edit_profile/edit_profile_screen.dart b/lib/modules/social_app/edit_profile/edit_profile_screen.dart index de27886..a109bcb 100644 --- a/lib/modules/social_app/edit_profile/edit_profile_screen.dart +++ b/lib/modules/social_app/edit_profile/edit_profile_screen.dart @@ -1,30 +1,29 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:image_picker/image_picker.dart'; import 'package:udemy_flutter/layout/social_app/cubit/cubit.dart'; import 'package:udemy_flutter/layout/social_app/cubit/states.dart'; import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/styles/icon_broken.dart'; class EditProfileScreen extends StatelessWidget { - var nameController = TextEditingController(); - var phoneController = TextEditingController(); - var bioController = TextEditingController(); + const EditProfileScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { + var nameController = TextEditingController(); + var phoneController = TextEditingController(); + var bioController = TextEditingController(); + return BlocConsumer( listener: (context, state) {}, builder: (context, state) { - var userModel = SocialCubit.get(context).userModel; + var userModel = SocialCubit.get(context).userModel!; var profileImage = SocialCubit.get(context).profileImage; var coverImage = SocialCubit.get(context).coverImage; - nameController.text = userModel.name; - phoneController.text = userModel.phone; - bioController.text = userModel.bio; + nameController.text = userModel.name!; + phoneController.text = userModel.phone!; + bioController.text = userModel.bio!; return Scaffold( appBar: defaultAppBar( @@ -40,28 +39,29 @@ class EditProfileScreen extends StatelessWidget { }, text: 'Update', ), - SizedBox( + const SizedBox( width: 15.0, ), ], - ), + ) as PreferredSizeWidget?, body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ if (state is SocialUserUpdateLoadingState) - LinearProgressIndicator(), + const LinearProgressIndicator(), if (state is SocialUserUpdateLoadingState) - SizedBox( + const SizedBox( height: 10.0, ), - Container( + SizedBox( height: 190.0, child: Stack( alignment: AlignmentDirectional.bottomCenter, children: [ Align( + alignment: AlignmentDirectional.topCenter, child: Stack( alignment: AlignmentDirectional.topEnd, children: [ @@ -69,7 +69,7 @@ class EditProfileScreen extends StatelessWidget { height: 140.0, width: double.infinity, decoration: BoxDecoration( - borderRadius: BorderRadius.only( + borderRadius: const BorderRadius.only( topLeft: Radius.circular( 4.0, ), @@ -78,20 +78,21 @@ class EditProfileScreen extends StatelessWidget { ), ), image: DecorationImage( - image: coverImage == null - ? NetworkImage( - '${userModel.cover}', - ) - : FileImage(coverImage), + image: (coverImage == null + ? NetworkImage( + '${userModel.cover}', + ) + : FileImage(coverImage)) + as ImageProvider, fit: BoxFit.cover, ), ), ), IconButton( - icon: CircleAvatar( + icon: const CircleAvatar( radius: 20.0, child: Icon( - IconBroken.Camera, + IconBroken.kCamera, size: 16.0, ), ), @@ -101,7 +102,6 @@ class EditProfileScreen extends StatelessWidget { ), ], ), - alignment: AlignmentDirectional.topCenter, ), Stack( alignment: AlignmentDirectional.bottomEnd, @@ -112,18 +112,19 @@ class EditProfileScreen extends StatelessWidget { Theme.of(context).scaffoldBackgroundColor, child: CircleAvatar( radius: 60.0, - backgroundImage: profileImage == null - ? NetworkImage( - '${userModel.image}', - ) - : FileImage(profileImage), + backgroundImage: (profileImage == null + ? NetworkImage( + '${userModel.image}', + ) + : FileImage(profileImage)) + as ImageProvider?, ), ), IconButton( - icon: CircleAvatar( + icon: const CircleAvatar( radius: 20.0, child: Icon( - IconBroken.Camera, + IconBroken.kCamera, size: 16.0, ), ), @@ -136,7 +137,7 @@ class EditProfileScreen extends StatelessWidget { ], ), ), - SizedBox( + const SizedBox( height: 20.0, ), if (SocialCubit.get(context).profileImage != null || @@ -158,15 +159,15 @@ class EditProfileScreen extends StatelessWidget { text: 'upload profile', ), if (state is SocialUserUpdateLoadingState) - SizedBox( - height: 5.0, - ), + const SizedBox( + height: 5.0, + ), if (state is SocialUserUpdateLoadingState) - LinearProgressIndicator(), + const LinearProgressIndicator(), ], ), ), - SizedBox( + const SizedBox( width: 5.0, ), if (SocialCubit.get(context).coverImage != null) @@ -174,8 +175,7 @@ class EditProfileScreen extends StatelessWidget { child: Column( children: [ defaultButton( - function: () - { + function: () { SocialCubit.get(context).uploadCoverImage( name: nameController.text, phone: phoneController.text, @@ -185,11 +185,11 @@ class EditProfileScreen extends StatelessWidget { text: 'upload cover', ), if (state is SocialUserUpdateLoadingState) - SizedBox( - height: 5.0, - ), + const SizedBox( + height: 5.0, + ), if (state is SocialUserUpdateLoadingState) - LinearProgressIndicator(), + const LinearProgressIndicator(), ], ), ), @@ -197,7 +197,7 @@ class EditProfileScreen extends StatelessWidget { ), if (SocialCubit.get(context).profileImage != null || SocialCubit.get(context).coverImage != null) - SizedBox( + const SizedBox( height: 20.0, ), defaultFormField( @@ -211,9 +211,9 @@ class EditProfileScreen extends StatelessWidget { return null; }, label: 'Name', - prefix: IconBroken.User, + prefix: IconBroken.kUser, ), - SizedBox( + const SizedBox( height: 10.0, ), defaultFormField( @@ -227,9 +227,9 @@ class EditProfileScreen extends StatelessWidget { return null; }, label: 'Bio', - prefix: IconBroken.Info_Circle, + prefix: IconBroken.kInfoCircle, ), - SizedBox( + const SizedBox( height: 10.0, ), defaultFormField( @@ -243,7 +243,7 @@ class EditProfileScreen extends StatelessWidget { return null; }, label: 'Phone', - prefix: IconBroken.Call, + prefix: IconBroken.kCall, ), ], ), diff --git a/lib/modules/social_app/feeds/feeds_screen.dart b/lib/modules/social_app/feeds/feeds_screen.dart index 20dde4c..35bb5be 100644 --- a/lib/modules/social_app/feeds/feeds_screen.dart +++ b/lib/modules/social_app/feeds/feeds_screen.dart @@ -1,5 +1,4 @@ -import 'dart:ui'; -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/social_app/cubit/cubit.dart'; @@ -10,6 +9,8 @@ import 'package:udemy_flutter/shared/styles/icon_broken.dart'; class FeedsScreen extends StatelessWidget { + const FeedsScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { @@ -18,22 +19,22 @@ class FeedsScreen extends StatelessWidget builder: (context, state) { return ConditionalBuilder( - condition: SocialCubit.get(context).posts.length > 0 && SocialCubit.get(context).userModel != null, + condition: SocialCubit.get(context).posts.isNotEmpty && SocialCubit.get(context).userModel != null, builder: (context) => SingleChildScrollView( - physics: BouncingScrollPhysics(), + physics: const BouncingScrollPhysics(), child: Column( children: [ Card( clipBehavior: Clip.antiAliasWithSaveLayer, elevation: 5.0, - margin: EdgeInsets.all( + margin: const EdgeInsets.all( 8.0, ), child: Stack( alignment: AlignmentDirectional.bottomEnd, children: [ - Image( + const Image( image: NetworkImage( 'https://image.freepik.com/free-photo/horizontal-shot-smiling-curly-haired-woman-indicates-free-space-demonstrates-place-your-advertisement-attracts-attention-sale-wears-green-turtleneck-isolated-vibrant-pink-wall_273609-42770.jpg', ), @@ -45,7 +46,7 @@ class FeedsScreen extends StatelessWidget padding: const EdgeInsets.all(8.0), child: Text( 'communicate with friends', - style: Theme.of(context).textTheme.subtitle1.copyWith( + style: Theme.of(context).textTheme.subtitle1!.copyWith( color: Colors.white, ), ), @@ -55,20 +56,20 @@ class FeedsScreen extends StatelessWidget ), ListView.separated( shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), + physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) => buildPostItem(SocialCubit.get(context).posts[index],context, index), - separatorBuilder: (context, index) => SizedBox( + separatorBuilder: (context, index) => const SizedBox( height: 8.0, ), itemCount: SocialCubit.get(context).posts.length, ), - SizedBox( + const SizedBox( height: 8.0, ), ], ), ), - fallback: (context) => Center(child: CircularProgressIndicator()), + fallback: (context) => const Center(child: CircularProgressIndicator()), ); }, ); @@ -77,7 +78,7 @@ class FeedsScreen extends StatelessWidget Widget buildPostItem(PostModel model, context, index) => Card( clipBehavior: Clip.antiAliasWithSaveLayer, elevation: 5.0, - margin: EdgeInsets.symmetric( + margin: const EdgeInsets.symmetric( horizontal: 8.0, ), child: Padding( @@ -93,7 +94,7 @@ class FeedsScreen extends StatelessWidget '${model.image}', ), ), - SizedBox( + const SizedBox( width: 15.0, ), Expanded( @@ -104,14 +105,14 @@ class FeedsScreen extends StatelessWidget children: [ Text( '${model.name}', - style: TextStyle( + style: const TextStyle( height: 1.4, ), ), - SizedBox( + const SizedBox( width: 5.0, ), - Icon( + const Icon( Icons.check_circle, color: defaultColor, size: 16.0, @@ -120,18 +121,18 @@ class FeedsScreen extends StatelessWidget ), Text( '${model.dateTime}', - style: Theme.of(context).textTheme.caption.copyWith( + style: Theme.of(context).textTheme.caption!.copyWith( height: 1.4, ), ), ], ), ), - SizedBox( + const SizedBox( width: 15.0, ), IconButton( - icon: Icon( + icon: const Icon( Icons.more_horiz, size: 16.0, ), @@ -241,12 +242,12 @@ class FeedsScreen extends StatelessWidget ), child: Row( children: [ - Icon( - IconBroken.Heart, + const Icon( + IconBroken.kHeart, size: 16.0, color: Colors.red, ), - SizedBox( + const SizedBox( width: 5.0, ), Text( @@ -268,12 +269,12 @@ class FeedsScreen extends StatelessWidget child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - Icon( - IconBroken.Chat, + const Icon( + IconBroken.kChat, size: 16.0, color: Colors.amber, ), - SizedBox( + const SizedBox( width: 5.0, ), Text( @@ -308,16 +309,16 @@ class FeedsScreen extends StatelessWidget CircleAvatar( radius: 18.0, backgroundImage: NetworkImage( - '${SocialCubit.get(context).userModel.image}', + '${SocialCubit.get(context).userModel!.image}', ), ), - SizedBox( + const SizedBox( width: 15.0, ), Text( 'write a comment ...', style: - Theme.of(context).textTheme.caption.copyWith(), + Theme.of(context).textTheme.caption!.copyWith(), ), ], ), @@ -327,12 +328,12 @@ class FeedsScreen extends StatelessWidget InkWell( child: Row( children: [ - Icon( - IconBroken.Heart, + const Icon( + IconBroken.kHeart, size: 16.0, color: Colors.red, ), - SizedBox( + const SizedBox( width: 5.0, ), Text( diff --git a/lib/modules/social_app/new_post/new_post_screen.dart b/lib/modules/social_app/new_post/new_post_screen.dart index d09fc9e..d2b43f7 100644 --- a/lib/modules/social_app/new_post/new_post_screen.dart +++ b/lib/modules/social_app/new_post/new_post_screen.dart @@ -5,12 +5,13 @@ import 'package:udemy_flutter/layout/social_app/cubit/states.dart'; import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/styles/icon_broken.dart'; -class NewPostScreen extends StatelessWidget -{ - var textController = TextEditingController(); +class NewPostScreen extends StatelessWidget { + const NewPostScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { + var textController = TextEditingController(); + return BlocConsumer( listener: (context, state) {}, builder: (context, state) { @@ -20,40 +21,37 @@ class NewPostScreen extends StatelessWidget title: 'Create Post', actions: [ defaultTextButton( - function: () - { + function: () { var now = DateTime.now(); - if (SocialCubit.get(context).postImage == null) - { + if (SocialCubit.get(context).postImage == null) { SocialCubit.get(context).createPost( dateTime: now.toString(), text: textController.text, ); - } else - { - SocialCubit.get(context).uploadPostImage( - dateTime: now.toString(), - text: textController.text, - ); - } + } else { + SocialCubit.get(context).uploadPostImage( + dateTime: now.toString(), + text: textController.text, + ); + } }, text: 'Post', ), ], - ), + ) as PreferredSizeWidget?, body: Padding( padding: const EdgeInsets.all(20.0), child: Column( children: [ - if(state is SocialCreatePostLoadingState) - LinearProgressIndicator(), - if(state is SocialCreatePostLoadingState) - SizedBox( - height: 10.0, - ), + if (state is SocialCreatePostLoadingState) + const LinearProgressIndicator(), + if (state is SocialCreatePostLoadingState) + const SizedBox( + height: 10.0, + ), Row( - children: [ + children: const [ CircleAvatar( radius: 25.0, backgroundImage: NetworkImage( @@ -76,61 +74,62 @@ class NewPostScreen extends StatelessWidget Expanded( child: TextFormField( controller: textController, - decoration: InputDecoration( + decoration: const InputDecoration( hintText: 'what is on your mind ...', border: InputBorder.none, ), ), ), - SizedBox( + const SizedBox( height: 20.0, ), - if(SocialCubit.get(context).postImage != null) + if (SocialCubit.get(context).postImage != null) Stack( - alignment: AlignmentDirectional.topEnd, - children: [ - Container( - height: 140.0, - width: double.infinity, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4.0,), - image: DecorationImage( - image: FileImage(SocialCubit.get(context).postImage), - fit: BoxFit.cover, + alignment: AlignmentDirectional.topEnd, + children: [ + Container( + height: 140.0, + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular( + 4.0, + ), + image: DecorationImage( + image: + FileImage(SocialCubit.get(context).postImage!), + fit: BoxFit.cover, + ), ), ), - ), - IconButton( - icon: CircleAvatar( - radius: 20.0, - child: Icon( - Icons.close, - size: 16.0, + IconButton( + icon: const CircleAvatar( + radius: 20.0, + child: Icon( + Icons.close, + size: 16.0, + ), ), + onPressed: () { + SocialCubit.get(context).removePostImage(); + }, ), - onPressed: () - { - SocialCubit.get(context).removePostImage(); - }, - ), - ], - ), - SizedBox( + ], + ), + const SizedBox( height: 20.0, ), Row( children: [ Expanded( child: TextButton( - onPressed: () - { + onPressed: () { SocialCubit.get(context).getPostImage(); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ Icon( - IconBroken.Image, + IconBroken.kImage, ), SizedBox( width: 5.0, @@ -145,7 +144,7 @@ class NewPostScreen extends StatelessWidget Expanded( child: TextButton( onPressed: () {}, - child: Text( + child: const Text( '# tags', ), ), diff --git a/lib/modules/social_app/settings/settings_screen.dart b/lib/modules/social_app/settings/settings_screen.dart index fea061d..edd6e6c 100644 --- a/lib/modules/social_app/settings/settings_screen.dart +++ b/lib/modules/social_app/settings/settings_screen.dart @@ -8,28 +8,31 @@ import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/styles/icon_broken.dart'; class SettingsScreen extends StatelessWidget { + const SettingsScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BlocConsumer( listener: (context, state) {}, builder: (context, state) { - var userModel = SocialCubit.get(context).userModel; + var userModel = SocialCubit.get(context).userModel!; return Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - Container( + SizedBox( height: 190.0, child: Stack( alignment: AlignmentDirectional.bottomCenter, children: [ Align( + alignment: AlignmentDirectional.topCenter, child: Container( height: 140.0, width: double.infinity, decoration: BoxDecoration( - borderRadius: BorderRadius.only( + borderRadius: const BorderRadius.only( topLeft: Radius.circular( 4.0, ), @@ -45,7 +48,6 @@ class SettingsScreen extends StatelessWidget { ), ), ), - alignment: AlignmentDirectional.topCenter, ), CircleAvatar( radius: 64.0, @@ -61,7 +63,7 @@ class SettingsScreen extends StatelessWidget { ], ), ), - SizedBox( + const SizedBox( height: 5.0, ), Text( @@ -154,23 +156,23 @@ class SettingsScreen extends StatelessWidget { Expanded( child: OutlinedButton( onPressed: () {}, - child: Text( + child: const Text( 'Add Photos', ), ), ), - SizedBox( + const SizedBox( width: 10.0, ), OutlinedButton( onPressed: () { navigateTo( context, - EditProfileScreen(), + const EditProfileScreen(), ); }, - child: Icon( - IconBroken.Edit, + child: const Icon( + IconBroken.kEdit, size: 16.0, ), ), @@ -183,11 +185,11 @@ class SettingsScreen extends StatelessWidget { { FirebaseMessaging.instance.subscribeToTopic('announcements'); }, - child: Text( + child: const Text( 'subscribe', ), ), - SizedBox( + const SizedBox( width: 20.0, ), OutlinedButton( @@ -195,7 +197,7 @@ class SettingsScreen extends StatelessWidget { { FirebaseMessaging.instance.unsubscribeFromTopic('announcements'); }, - child: Text( + child: const Text( 'unsubscribe', ), ), diff --git a/lib/modules/social_app/social_login/cubit/cubit.dart b/lib/modules/social_app/social_login/cubit/cubit.dart index 47163b0..3e68ce2 100644 --- a/lib/modules/social_app/social_login/cubit/cubit.dart +++ b/lib/modules/social_app/social_login/cubit/cubit.dart @@ -1,5 +1,4 @@ import 'package:firebase_auth/firebase_auth.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/modules/social_app/social_login/cubit/states.dart'; @@ -10,8 +9,8 @@ class SocialLoginCubit extends Cubit { static SocialLoginCubit get(context) => BlocProvider.of(context); void userLogin({ - @required String email, - @required String password, + required String email, + required String password, }) { emit(SocialLoginLoadingState()); @@ -21,9 +20,9 @@ class SocialLoginCubit extends Cubit { password: password, ) .then((value) { - print(value.user.email); - print(value.user.uid); - emit(SocialLoginSuccessState(value.user.uid)); + debugPrint(value.user!.email); + debugPrint(value.user!.uid); + emit(SocialLoginSuccessState(value.user!.uid)); }) .catchError((error) { diff --git a/lib/modules/social_app/social_login/social_login_screen.dart b/lib/modules/social_app/social_login/social_login_screen.dart index 3da6ee4..f633ca8 100644 --- a/lib/modules/social_app/social_login/social_login_screen.dart +++ b/lib/modules/social_app/social_login/social_login_screen.dart @@ -1,4 +1,4 @@ -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/social_app/social_layout.dart'; @@ -9,12 +9,15 @@ import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/network/local/cache_helper.dart'; class SocialLoginScreen extends StatelessWidget { - var formKey = GlobalKey(); - var emailController = TextEditingController(); - var passwordController = TextEditingController(); + const SocialLoginScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { + var formKey = GlobalKey(); + var emailController = TextEditingController(); + var passwordController = TextEditingController(); + return BlocProvider( create: (BuildContext context) => SocialLoginCubit(), child: BlocConsumer( @@ -22,7 +25,7 @@ class SocialLoginScreen extends StatelessWidget { if (state is SocialLoginErrorState) { showToast( text: state.error, - state: ToastStates.ERROR, + state: ToastStates.kERROR, ); } if(state is SocialLoginSuccessState) @@ -34,7 +37,7 @@ class SocialLoginScreen extends StatelessWidget { { navigateAndFinish( context, - SocialLayout(), + const SocialLayout(), ); }); } @@ -53,17 +56,17 @@ class SocialLoginScreen extends StatelessWidget { children: [ Text( 'LOGIN', - style: Theme.of(context).textTheme.headline4.copyWith( + style: Theme.of(context).textTheme.headline4!.copyWith( color: Colors.black, ), ), Text( 'Login now to communicate with friends', - style: Theme.of(context).textTheme.bodyText1.copyWith( + style: Theme.of(context).textTheme.bodyText1!.copyWith( color: Colors.grey, ), ), - SizedBox( + const SizedBox( height: 30.0, ), defaultFormField( @@ -77,7 +80,7 @@ class SocialLoginScreen extends StatelessWidget { label: 'Email Address', prefix: Icons.email_outlined, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( @@ -85,7 +88,7 @@ class SocialLoginScreen extends StatelessWidget { type: TextInputType.visiblePassword, suffix: SocialLoginCubit.get(context).suffix, onSubmit: (value) { - if (formKey.currentState.validate()) { + if (formKey.currentState!.validate()) { // SocialLoginCubit.get(context).userLogin( // email: emailController.text, // password: passwordController.text, @@ -105,14 +108,14 @@ class SocialLoginScreen extends StatelessWidget { label: 'Password', prefix: Icons.lock_outline, ), - SizedBox( + const SizedBox( height: 30.0, ), ConditionalBuilder( condition: state is! SocialLoginLoadingState, builder: (context) => defaultButton( function: () { - if (formKey.currentState.validate()) { + if (formKey.currentState!.validate()) { SocialLoginCubit.get(context).userLogin( email: emailController.text, password: passwordController.text, @@ -123,22 +126,22 @@ class SocialLoginScreen extends StatelessWidget { isUpperCase: true, ), fallback: (context) => - Center(child: CircularProgressIndicator()), + const Center(child: CircularProgressIndicator()), ), - SizedBox( + const SizedBox( height: 15.0, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( + const Text( 'Don\'t have an account?', ), defaultTextButton( function: () { navigateTo( context, - SocialRegisterScreen(), + const SocialRegisterScreen(), ); }, text: 'register', diff --git a/lib/modules/social_app/social_register/cubit/cubit.dart b/lib/modules/social_app/social_register/cubit/cubit.dart index bbf280c..eaa931f 100644 --- a/lib/modules/social_app/social_register/cubit/cubit.dart +++ b/lib/modules/social_app/social_register/cubit/cubit.dart @@ -1,15 +1,9 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:udemy_flutter/models/shop_app/login_model.dart'; import 'package:udemy_flutter/models/social_app/social_user_model.dart'; -import 'package:udemy_flutter/modules/shop_app/login/cubit/states.dart'; -import 'package:udemy_flutter/modules/shop_app/register/cubit/states.dart'; import 'package:udemy_flutter/modules/social_app/social_register/cubit/states.dart'; -import 'package:udemy_flutter/shared/network/end_points.dart'; -import 'package:udemy_flutter/shared/network/remote/dio_helper.dart'; class SocialRegisterCubit extends Cubit { SocialRegisterCubit() : super(SocialRegisterInitialState()); @@ -17,12 +11,12 @@ class SocialRegisterCubit extends Cubit { static SocialRegisterCubit get(context) => BlocProvider.of(context); void userRegister({ - @required String name, - @required String email, - @required String password, - @required String phone, + required String name, + required String email, + required String password, + required String phone, }) { - print('hello'); + debugPrint('hello'); emit(SocialRegisterLoadingState()); @@ -33,7 +27,7 @@ class SocialRegisterCubit extends Cubit { ) .then((value) { userCreate( - uId: value.user.uid, + uId: value.user!.uid, phone: phone, email: email, name: name, @@ -45,10 +39,10 @@ class SocialRegisterCubit extends Cubit { } void userCreate({ - @required String name, - @required String email, - @required String phone, - @required String uId, + required String name, + required String email, + required String phone, + required String uId, }) { SocialUserModel model = SocialUserModel( name: name, @@ -70,7 +64,7 @@ class SocialRegisterCubit extends Cubit { emit(SocialCreateUserSuccessState()); }) .catchError((error) { - print(error.toString()); + debugPrint(error.toString()); emit(SocialCreateUserErrorState(error.toString())); }); } diff --git a/lib/modules/social_app/social_register/social_register_screen.dart b/lib/modules/social_app/social_register/social_register_screen.dart index 84e9fda..31cc162 100644 --- a/lib/modules/social_app/social_register/social_register_screen.dart +++ b/lib/modules/social_app/social_register/social_register_screen.dart @@ -1,4 +1,4 @@ -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/layout/social_app/social_layout.dart'; @@ -7,14 +7,17 @@ import 'package:udemy_flutter/modules/social_app/social_register/cubit/states.da import 'package:udemy_flutter/shared/components/components.dart'; class SocialRegisterScreen extends StatelessWidget { - var formKey = GlobalKey(); - var nameController = TextEditingController(); - var emailController = TextEditingController(); - var passwordController = TextEditingController(); - var phoneController = TextEditingController(); + const SocialRegisterScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { + var formKey = GlobalKey(); + var nameController = TextEditingController(); + var emailController = TextEditingController(); + var passwordController = TextEditingController(); + var phoneController = TextEditingController(); + return BlocProvider( create: (BuildContext context) => SocialRegisterCubit(), child: BlocConsumer( @@ -22,7 +25,7 @@ class SocialRegisterScreen extends StatelessWidget { if (state is SocialCreateUserSuccessState) { navigateAndFinish( context, - SocialLayout(), + const SocialLayout(), ); } }, @@ -40,17 +43,17 @@ class SocialRegisterScreen extends StatelessWidget { children: [ Text( 'REGISTER', - style: Theme.of(context).textTheme.headline4.copyWith( + style: Theme.of(context).textTheme.headline4!.copyWith( color: Colors.black, ), ), Text( 'Register now to communicate with friends', - style: Theme.of(context).textTheme.bodyText1.copyWith( + style: Theme.of(context).textTheme.bodyText1!.copyWith( color: Colors.grey, ), ), - SizedBox( + const SizedBox( height: 30.0, ), defaultFormField( @@ -64,7 +67,7 @@ class SocialRegisterScreen extends StatelessWidget { label: 'User Name', prefix: Icons.person, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( @@ -78,7 +81,7 @@ class SocialRegisterScreen extends StatelessWidget { label: 'Email Address', prefix: Icons.email_outlined, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( @@ -100,7 +103,7 @@ class SocialRegisterScreen extends StatelessWidget { label: 'Password', prefix: Icons.lock_outline, ), - SizedBox( + const SizedBox( height: 15.0, ), defaultFormField( @@ -114,14 +117,14 @@ class SocialRegisterScreen extends StatelessWidget { label: 'Phone', prefix: Icons.phone, ), - SizedBox( + const SizedBox( height: 30.0, ), ConditionalBuilder( condition: state is! SocialRegisterLoadingState, builder: (context) => defaultButton( function: () { - if (formKey.currentState.validate()) { + if (formKey.currentState!.validate()) { SocialRegisterCubit.get(context).userRegister( name: nameController.text, email: emailController.text, @@ -134,7 +137,7 @@ class SocialRegisterScreen extends StatelessWidget { isUpperCase: true, ), fallback: (context) => - Center(child: CircularProgressIndicator()), + const Center(child: CircularProgressIndicator()), ), ], ), diff --git a/lib/modules/social_app/users/users_screen.dart b/lib/modules/social_app/users/users_screen.dart index f21c2f2..1429006 100644 --- a/lib/modules/social_app/users/users_screen.dart +++ b/lib/modules/social_app/users/users_screen.dart @@ -2,10 +2,12 @@ import 'package:flutter/material.dart'; class UsersScreen extends StatelessWidget { + const UsersScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Text( + return const Text( 'Users', ); } diff --git a/lib/modules/todo_app/archived_tasks/archived_tasks_screen.dart b/lib/modules/todo_app/archived_tasks/archived_tasks_screen.dart index aaf2a2a..ead0d1d 100644 --- a/lib/modules/todo_app/archived_tasks/archived_tasks_screen.dart +++ b/lib/modules/todo_app/archived_tasks/archived_tasks_screen.dart @@ -6,6 +6,8 @@ import 'package:udemy_flutter/shared/cubit/states.dart'; class ArchivedTasksScreen extends StatelessWidget { + const ArchivedTasksScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BlocConsumer( diff --git a/lib/modules/todo_app/done_tasks/done_tasks_screen.dart b/lib/modules/todo_app/done_tasks/done_tasks_screen.dart index 3fc2ccb..2bbb38d 100644 --- a/lib/modules/todo_app/done_tasks/done_tasks_screen.dart +++ b/lib/modules/todo_app/done_tasks/done_tasks_screen.dart @@ -5,6 +5,8 @@ import 'package:udemy_flutter/shared/cubit/cubit.dart'; import 'package:udemy_flutter/shared/cubit/states.dart'; class DoneTasksScreen extends StatelessWidget { + const DoneTasksScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BlocConsumer( diff --git a/lib/modules/todo_app/new_tasks/new_tasks_screen.dart b/lib/modules/todo_app/new_tasks/new_tasks_screen.dart index a2f8dbe..53daaa6 100644 --- a/lib/modules/todo_app/new_tasks/new_tasks_screen.dart +++ b/lib/modules/todo_app/new_tasks/new_tasks_screen.dart @@ -1,13 +1,13 @@ -import 'package:conditional_builder/conditional_builder.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:udemy_flutter/shared/components/components.dart'; -import 'package:udemy_flutter/shared/components/constants.dart'; import 'package:udemy_flutter/shared/cubit/cubit.dart'; import 'package:udemy_flutter/shared/cubit/states.dart'; class NewTasksScreen extends StatelessWidget { + const NewTasksScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { diff --git a/lib/shared/bloc_observer.dart b/lib/shared/bloc_observer.dart index 59a5a5d..9b67439 100644 --- a/lib/shared/bloc_observer.dart +++ b/lib/shared/bloc_observer.dart @@ -1,28 +1,29 @@ import 'package:bloc/bloc.dart'; +import 'package:flutter/foundation.dart'; class MyBlocObserver extends BlocObserver { @override void onCreate(BlocBase bloc) { super.onCreate(bloc); - print('onCreate -- ${bloc.runtimeType}'); + debugPrint('onCreate -- ${bloc.runtimeType}'); } @override void onChange(BlocBase bloc, Change change) { super.onChange(bloc, change); - print('onChange -- ${bloc.runtimeType}, $change'); + debugPrint('onChange -- ${bloc.runtimeType}, $change'); } @override void onError(BlocBase bloc, Object error, StackTrace stackTrace) { - print('onError -- ${bloc.runtimeType}, $error'); + debugPrint('onError -- ${bloc.runtimeType}, $error'); super.onError(bloc, error, stackTrace); } @override void onClose(BlocBase bloc) { super.onClose(bloc); - print('onClose -- ${bloc.runtimeType}'); + debugPrint('onClose -- ${bloc.runtimeType}'); } } \ No newline at end of file diff --git a/lib/shared/components/components.dart b/lib/shared/components/components.dart index 41789f0..e907abf 100644 --- a/lib/shared/components/components.dart +++ b/lib/shared/components/components.dart @@ -1,4 +1,4 @@ -import 'package:conditional_builder/conditional_builder.dart'; +import 'package:conditional_builder_null_safety/conditional_builder_null_safety.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:udemy_flutter/layout/shop_app/cubit/cubit.dart'; @@ -12,52 +12,52 @@ Widget defaultButton({ Color background = Colors.blue, bool isUpperCase = true, double radius = 3.0, - @required Function function, - @required String text, + required Function function, + required String text, }) => Container( width: width, height: 40.0, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular( + radius, + ), + color: background, + ), child: MaterialButton( - onPressed: function, + onPressed: function as void Function()?, child: Text( isUpperCase ? text.toUpperCase() : text, - style: TextStyle( + style: const TextStyle( color: Colors.white, ), ), ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular( - radius, - ), - color: background, - ), ); Widget defaultTextButton({ - @required Function function, - @required String text, + required Function function, + required String text, }) => TextButton( - onPressed: function, + onPressed: function as void Function()?, child: Text( text.toUpperCase(), ), ); Widget defaultFormField({ - @required TextEditingController controller, - @required TextInputType type, - Function onSubmit, - Function onChange, - Function onTap, + required TextEditingController controller, + required TextInputType type, + Function? onSubmit, + Function? onChange, + Function? onTap, bool isPassword = false, - @required Function validate, - @required String label, - @required IconData prefix, - IconData suffix, - Function suffixPressed, + required Function validate, + required String label, + required IconData prefix, + IconData? suffix, + Function? suffixPressed, bool isClickable = true, }) => TextFormField( @@ -65,10 +65,10 @@ Widget defaultFormField({ keyboardType: type, obscureText: isPassword, enabled: isClickable, - onFieldSubmitted: onSubmit, - onChanged: onChange, - onTap: onTap, - validator: validate, + onFieldSubmitted: onSubmit as void Function(String)?, + onChanged: onChange as void Function(String)?, + onTap: onTap as void Function()?, + validator: validate as String? Function(String?)?, decoration: InputDecoration( labelText: label, prefixIcon: Icon( @@ -76,28 +76,28 @@ Widget defaultFormField({ ), suffixIcon: suffix != null ? IconButton( - onPressed: suffixPressed, + onPressed: suffixPressed as void Function()?, icon: Icon( suffix, ), ) : null, - border: OutlineInputBorder(), + border: const OutlineInputBorder(), ), ); Widget defaultAppBar({ - @required BuildContext context, - String title, - List actions, + required BuildContext context, + required String title, + List? actions, }) => AppBar( leading: IconButton( onPressed: () { Navigator.pop(context); }, - icon: Icon( - IconBroken.Arrow___Left_2, + icon: const Icon( + IconBroken.kArrowLeft2, ), ), titleSpacing: 5.0, @@ -119,7 +119,7 @@ Widget buildTaskItem(Map model, context) => Dismissible( '${model['time']}', ), ), - SizedBox( + const SizedBox( width: 20.0, ), Expanded( @@ -129,21 +129,21 @@ Widget buildTaskItem(Map model, context) => Dismissible( children: [ Text( '${model['title']}', - style: TextStyle( + style: const TextStyle( fontSize: 18.0, fontWeight: FontWeight.bold, ), ), Text( '${model['date']}', - style: TextStyle( + style: const TextStyle( color: Colors.grey, ), ), ], ), ), - SizedBox( + const SizedBox( width: 20.0, ), IconButton( @@ -153,7 +153,7 @@ Widget buildTaskItem(Map model, context) => Dismissible( id: model['id'], ); }, - icon: Icon( + icon: const Icon( Icons.check_box, color: Colors.green, ), @@ -165,7 +165,7 @@ Widget buildTaskItem(Map model, context) => Dismissible( id: model['id'], ); }, - icon: Icon( + icon: const Icon( Icons.archive, color: Colors.black45, ), @@ -181,10 +181,10 @@ Widget buildTaskItem(Map model, context) => Dismissible( ); Widget tasksBuilder({ - @required List tasks, + required List tasks, }) => ConditionalBuilder( - condition: tasks.length > 0, + condition: tasks.isNotEmpty, builder: (context) => ListView.separated( itemBuilder: (context, index) { return buildTaskItem(tasks[index], context); @@ -195,7 +195,7 @@ Widget tasksBuilder({ fallback: (context) => Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ Icon( Icons.menu, size: 100.0, @@ -249,11 +249,11 @@ Widget buildArticleItem(article, context) => InkWell( ), ), ), - SizedBox( + const SizedBox( width: 20.0, ), Expanded( - child: Container( + child: SizedBox( height: 120.0, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -269,7 +269,7 @@ Widget buildArticleItem(article, context) => InkWell( ), Text( '${article['publishedAt']}', - style: TextStyle( + style: const TextStyle( color: Colors.grey, ), ), @@ -277,7 +277,7 @@ Widget buildArticleItem(article, context) => InkWell( ), ), ), - SizedBox( + const SizedBox( width: 15.0, ), ], @@ -288,13 +288,13 @@ Widget buildArticleItem(article, context) => InkWell( Widget articleBuilder(list, context, {isSearch = false}) => ConditionalBuilder( condition: list.length > 0, builder: (context) => ListView.separated( - physics: BouncingScrollPhysics(), + physics: const BouncingScrollPhysics(), itemBuilder: (context, index) => buildArticleItem(list[index], context), separatorBuilder: (context, index) => myDivider(), itemCount: 10, ), fallback: (context) => - isSearch ? Container() : Center(child: CircularProgressIndicator()), + isSearch ? Container() : const Center(child: CircularProgressIndicator()), ); void navigateTo(context, widget) => Navigator.push( @@ -319,8 +319,8 @@ void navigateAndFinish( ); void showToast({ - @required String text, - @required ToastStates state, + required String text, + required ToastStates state, }) => Fluttertoast.showToast( msg: text, @@ -333,19 +333,19 @@ void showToast({ ); // enum -enum ToastStates { SUCCESS, ERROR, WARNING } +enum ToastStates { kSUCCESS, kERROR, kWARNING } -Color chooseToastColor(ToastStates state) { - Color color; +Color? chooseToastColor(ToastStates state) { + Color? color; switch (state) { - case ToastStates.SUCCESS: + case ToastStates.kSUCCESS: color = Colors.green; break; - case ToastStates.ERROR: + case ToastStates.kERROR: color = Colors.red; break; - case ToastStates.WARNING: + case ToastStates.kWARNING: color = Colors.amber; break; } @@ -360,7 +360,7 @@ Widget buildListProduct( }) => Padding( padding: const EdgeInsets.all(20.0), - child: Container( + child: SizedBox( height: 120.0, child: Row( children: [ @@ -375,10 +375,10 @@ Widget buildListProduct( if (model.discount != 0 && isOldPrice) Container( color: Colors.red, - padding: EdgeInsets.symmetric( + padding: const EdgeInsets.symmetric( horizontal: 5.0, ), - child: Text( + child: const Text( 'DISCOUNT', style: TextStyle( fontSize: 8.0, @@ -388,7 +388,7 @@ Widget buildListProduct( ), ], ), - SizedBox( + const SizedBox( width: 20.0, ), Expanded( @@ -399,34 +399,34 @@ Widget buildListProduct( model.name, maxLines: 2, overflow: TextOverflow.ellipsis, - style: TextStyle( + style: const TextStyle( fontSize: 14.0, height: 1.3, ), ), - Spacer(), + const Spacer(), Row( children: [ Text( model.price.toString(), - style: TextStyle( + style: const TextStyle( fontSize: 12.0, color: defaultColor, ), ), - SizedBox( + const SizedBox( width: 5.0, ), if (model.discount != 0 && isOldPrice) Text( model.oldPrice.toString(), - style: TextStyle( + style: const TextStyle( fontSize: 10.0, color: Colors.grey, decoration: TextDecoration.lineThrough, ), ), - Spacer(), + const Spacer(), IconButton( onPressed: () { ShopCubit.get(context).changeFavorites(model.id); @@ -434,10 +434,10 @@ Widget buildListProduct( icon: CircleAvatar( radius: 15.0, backgroundColor: - ShopCubit.get(context).favorites[model.id] + ShopCubit.get(context).favorites[model.id]! ? defaultColor : Colors.grey, - child: Icon( + child: const Icon( Icons.favorite_border, size: 14.0, color: Colors.white, diff --git a/lib/shared/components/constants.dart b/lib/shared/components/constants.dart index c3f2eaf..52e5733 100644 --- a/lib/shared/components/constants.dart +++ b/lib/shared/components/constants.dart @@ -10,6 +10,7 @@ // https://newsapi.org/v2/everything?q=tesla&apiKey=65f7f556ec76449fa7dc7c0069f040ca +import 'package:flutter/foundation.dart'; import 'package:udemy_flutter/modules/shop_app/login/shop_login_screen.dart'; import 'package:udemy_flutter/shared/components/components.dart'; import 'package:udemy_flutter/shared/network/local/cache_helper.dart'; @@ -24,7 +25,7 @@ void signOut(context) { navigateAndFinish( context, - ShopLoginScreen(), + const ShopLoginScreen(), ); } }); @@ -32,9 +33,9 @@ void signOut(context) void printFullText(String text) { final pattern = RegExp('.{1,800}'); // 800 is the size of each chunk - pattern.allMatches(text).forEach((match) => print(match.group(0))); + pattern.allMatches(text).forEach((match) => debugPrint(match.group(0))); } -String token = ''; +String? token = ''; -String uId = ''; \ No newline at end of file +String? uId = ''; \ No newline at end of file diff --git a/lib/shared/cubit/cubit.dart b/lib/shared/cubit/cubit.dart index 3620a5c..2b52e16 100644 --- a/lib/shared/cubit/cubit.dart +++ b/lib/shared/cubit/cubit.dart @@ -15,9 +15,9 @@ class AppCubit extends Cubit { int currentIndex = 0; List screens = [ - NewTasksScreen(), - DoneTasksScreen(), - ArchivedTasksScreen(), + const NewTasksScreen(), + const DoneTasksScreen(), + const ArchivedTasksScreen(), ]; List titles = [ @@ -31,7 +31,7 @@ class AppCubit extends Cubit { emit(AppChangeBottomNavBarState()); } - Database database; + late Database database; List newTasks = []; List doneTasks = []; List archivedTasks = []; @@ -47,19 +47,19 @@ class AppCubit extends Cubit { // time String // status String - print('database created'); + debugPrint('database created'); database .execute( 'CREATE TABLE tasks (id INTEGER PRIMARY KEY, title TEXT, date TEXT, time TEXT, status TEXT)') .then((value) { - print('table created'); + debugPrint('table created'); }).catchError((error) { - print('Error When Creating Table ${error.toString()}'); + debugPrint('Error When Creating Table ${error.toString()}'); }); }, onOpen: (database) { getDataFromDatabase(database); - print('database opened'); + debugPrint('database opened'); }, ).then((value) { database = value; @@ -68,9 +68,9 @@ class AppCubit extends Cubit { } insertToDatabase({ - @required String title, - @required String time, - @required String date, + required String title, + required String time, + required String date, }) async { await database.transaction((txn) { txn @@ -78,16 +78,16 @@ class AppCubit extends Cubit { 'INSERT INTO tasks(title, date, time, status) VALUES("$title", "$date", "$time", "new")', ) .then((value) { - print('$value inserted successfully'); + debugPrint('$value inserted successfully'); emit(AppInsertDatabaseState()); getDataFromDatabase(database); }).catchError((error) { - print('Error When Inserting New Record ${error.toString()}'); + debugPrint('Error When Inserting New Record ${error.toString()}'); }); return null; - }); + } as Future Function(Transaction)); } void getDataFromDatabase(database) { @@ -99,12 +99,13 @@ class AppCubit extends Cubit { database.rawQuery('SELECT * FROM tasks').then((value) { value.forEach((element) { - if (element['status'] == 'new') + if (element['status'] == 'new') { newTasks.add(element); - else if (element['status'] == 'done') + } else if (element['status'] == 'done') { doneTasks.add(element); - else + } else { archivedTasks.add(element); + } }); emit(AppGetDatabaseState()); @@ -112,12 +113,12 @@ class AppCubit extends Cubit { } void updateData({ - @required String status, - @required int id, + required String status, + required int? id, }) async { database.rawUpdate( 'UPDATE tasks SET status = ? WHERE id = ?', - ['$status', id], + [status, id], ).then((value) { getDataFromDatabase(database); emit(AppUpdateDatabaseState()); @@ -125,7 +126,7 @@ class AppCubit extends Cubit { } void deleteData({ - @required int id, + required int? id, }) async { database.rawDelete('DELETE FROM tasks WHERE id = ?', [id]).then((value) { getDataFromDatabase(database); @@ -137,8 +138,8 @@ class AppCubit extends Cubit { IconData fabIcon = Icons.edit; void changeBottomSheetState({ - @required bool isShow, - @required IconData icon, + required bool isShow, + required IconData icon, }) { isBottomSheetShown = isShow; fabIcon = icon; @@ -148,7 +149,7 @@ class AppCubit extends Cubit { bool isDark = false; - void changeAppMode({bool fromShared}) + void changeAppMode({bool? fromShared}) { if (fromShared != null) { diff --git a/lib/shared/network/end_points.dart b/lib/shared/network/end_points.dart index 9379fed..974d500 100644 --- a/lib/shared/network/end_points.dart +++ b/lib/shared/network/end_points.dart @@ -1,15 +1,15 @@ -const LOGIN = 'login'; +const kLOGIN = 'login'; -const REGISTER = 'register'; +const kREGISTER = 'register'; -const HOME = 'home'; +const kHOME = 'home'; -const GET_CATEGORIES = 'categories'; +const kGetCATEGORIES = 'categories'; -const FAVORITES = 'favorites'; +const kFAVORITES = 'favorites'; -const PROFILE = 'profile'; +const kPROFILE = 'profile'; -const UPDATE_PROFILE = 'update-profile'; +const kUpdatePROFILE = 'update-profile'; -const SEARCH = 'products/search'; \ No newline at end of file +const kSEARCH = 'products/search'; \ No newline at end of file diff --git a/lib/shared/network/local/cache_helper.dart b/lib/shared/network/local/cache_helper.dart index fffdd2b..4d02e68 100644 --- a/lib/shared/network/local/cache_helper.dart +++ b/lib/shared/network/local/cache_helper.dart @@ -1,9 +1,8 @@ -import 'package:flutter/cupertino.dart'; import 'package:shared_preferences/shared_preferences.dart'; class CacheHelper { - static SharedPreferences sharedPreferences; + static late SharedPreferences sharedPreferences; static init() async { @@ -11,22 +10,22 @@ class CacheHelper } static Future putBoolean({ - @required String key, - @required bool value, + required String key, + required bool value, }) async { return await sharedPreferences.setBool(key, value); } static dynamic getData({ - @required String key, + required String key, }) { return sharedPreferences.get(key); } static Future saveData({ - @required String key, - @required dynamic value, + required String key, + required dynamic value, }) async { if (value is String) return await sharedPreferences.setString(key, value); if (value is int) return await sharedPreferences.setInt(key, value); @@ -36,7 +35,7 @@ class CacheHelper } static Future removeData({ - @required String key, + required String key, }) async { return await sharedPreferences.remove(key); diff --git a/lib/shared/network/remote/dio_helper.dart b/lib/shared/network/remote/dio_helper.dart index 2698c46..1ee1092 100644 --- a/lib/shared/network/remote/dio_helper.dart +++ b/lib/shared/network/remote/dio_helper.dart @@ -1,8 +1,7 @@ import 'package:dio/dio.dart'; -import 'package:flutter/cupertino.dart'; class DioHelper { - static Dio dio; + static late Dio dio; static init() { @@ -15,10 +14,10 @@ class DioHelper { } static Future getData({ - @required String url, - Map query, + required String url, + Map? query, String lang = 'en', - String token, + String? token, }) async { dio.options.headers = @@ -35,11 +34,11 @@ class DioHelper { } static Future postData({ - @required String url, - @required Map data, - Map query, + required String url, + required Map data, + Map? query, String lang = 'en', - String token, + String? token, }) async { dio.options.headers = @@ -57,11 +56,11 @@ class DioHelper { } static Future putData({ - @required String url, - @required Map data, - Map query, + required String url, + required Map data, + Map? query, String lang = 'en', - String token, + String? token, }) async { dio.options.headers = diff --git a/lib/shared/styles/icon_broken.dart b/lib/shared/styles/icon_broken.dart index d405a7f..ab81950 100644 --- a/lib/shared/styles/icon_broken.dart +++ b/lib/shared/styles/icon_broken.dart @@ -12,104 +12,104 @@ class IconBroken { static const String _fontFamily = 'IconBroken'; - static const IconData User = IconData(0xe900, fontFamily: _fontFamily); - static const IconData User1 = IconData(0xe901, fontFamily: _fontFamily); - static const IconData Activity = IconData(0xe902, fontFamily: _fontFamily); - static const IconData Add_User = IconData(0xe903, fontFamily: _fontFamily); - static const IconData Arrow___Down_2 = IconData(0xe904, fontFamily: _fontFamily); - static const IconData Arrow___Down_3 = IconData(0xe905, fontFamily: _fontFamily); - static const IconData Arrow___Down_Circle = IconData(0xe906, fontFamily: _fontFamily); - static const IconData Arrow___Down_Square = IconData(0xe907, fontFamily: _fontFamily); - static const IconData Arrow___Down = IconData(0xe908, fontFamily: _fontFamily); - static const IconData Arrow___Left_2 = IconData(0xe909, fontFamily: _fontFamily); - static const IconData Arrow___Left_3 = IconData(0xe90a, fontFamily: _fontFamily); - static const IconData Arrow___Left_Circle = IconData(0xe90b, fontFamily: _fontFamily); - static const IconData Arrow___Left_Square = IconData(0xe90c, fontFamily: _fontFamily); - static const IconData Arrow___Left = IconData(0xe90d, fontFamily: _fontFamily); - static const IconData Arrow___Right_2 = IconData(0xe90e, fontFamily: _fontFamily); - static const IconData Arrow___Right_3 = IconData(0xe90f, fontFamily: _fontFamily); - static const IconData Arrow___Right_Circle = IconData(0xe910, fontFamily: _fontFamily); - static const IconData Arrow___Right_Square = IconData(0xe911, fontFamily: _fontFamily); - static const IconData Arrow___Right = IconData(0xe912, fontFamily: _fontFamily); - static const IconData Arrow___Up_2 = IconData(0xe913, fontFamily: _fontFamily); - static const IconData Arrow___Up_3 = IconData(0xe914, fontFamily: _fontFamily); - static const IconData Arrow___Up_Circle = IconData(0xe915, fontFamily: _fontFamily); - static const IconData Arrow___Up_Square = IconData(0xe916, fontFamily: _fontFamily); - static const IconData Arrow___Up = IconData(0xe917, fontFamily: _fontFamily); - static const IconData Bag_2 = IconData(0xe918, fontFamily: _fontFamily); - static const IconData Bag = IconData(0xe919, fontFamily: _fontFamily); - static const IconData Bookmark = IconData(0xe91a, fontFamily: _fontFamily); - static const IconData Buy = IconData(0xe91b, fontFamily: _fontFamily); - static const IconData Calendar = IconData(0xe91c, fontFamily: _fontFamily); - static const IconData Call_Missed = IconData(0xe91d, fontFamily: _fontFamily); - static const IconData Call_Silent = IconData(0xe91e, fontFamily: _fontFamily); - static const IconData Call = IconData(0xe91f, fontFamily: _fontFamily); - static const IconData Calling = IconData(0xe920, fontFamily: _fontFamily); - static const IconData Camera = IconData(0xe921, fontFamily: _fontFamily); - static const IconData Category = IconData(0xe922, fontFamily: _fontFamily); - static const IconData Chart = IconData(0xe923, fontFamily: _fontFamily); - static const IconData Chat = IconData(0xe924, fontFamily: _fontFamily); - static const IconData Close_Square = IconData(0xe925, fontFamily: _fontFamily); - static const IconData Danger = IconData(0xe926, fontFamily: _fontFamily); - static const IconData Delete = IconData(0xe927, fontFamily: _fontFamily); - static const IconData Discount = IconData(0xe928, fontFamily: _fontFamily); - static const IconData Discovery = IconData(0xe929, fontFamily: _fontFamily); - static const IconData Document = IconData(0xe92a, fontFamily: _fontFamily); - static const IconData Download = IconData(0xe92b, fontFamily: _fontFamily); - static const IconData Edit_Square = IconData(0xe92c, fontFamily: _fontFamily); - static const IconData Edit = IconData(0xe92d, fontFamily: _fontFamily); - static const IconData Filter_2 = IconData(0xe92e, fontFamily: _fontFamily); - static const IconData Filter = IconData(0xe92f, fontFamily: _fontFamily); - static const IconData Folder = IconData(0xe930, fontFamily: _fontFamily); - static const IconData Game = IconData(0xe931, fontFamily: _fontFamily); - static const IconData Graph = IconData(0xe932, fontFamily: _fontFamily); - static const IconData Heart = IconData(0xe933, fontFamily: _fontFamily); - static const IconData Hide = IconData(0xe934, fontFamily: _fontFamily); - static const IconData Home = IconData(0xe935, fontFamily: _fontFamily); - static const IconData Image_2 = IconData(0xe936, fontFamily: _fontFamily); - static const IconData Image = IconData(0xe937, fontFamily: _fontFamily); - static const IconData Info_Circle = IconData(0xe938, fontFamily: _fontFamily); - static const IconData Info_Square = IconData(0xe939, fontFamily: _fontFamily); - static const IconData Location = IconData(0xe93a, fontFamily: _fontFamily); - static const IconData Lock = IconData(0xe93b, fontFamily: _fontFamily); - static const IconData Login = IconData(0xe93c, fontFamily: _fontFamily); - static const IconData Logout = IconData(0xe93d, fontFamily: _fontFamily); - static const IconData Message = IconData(0xe93e, fontFamily: _fontFamily); - static const IconData More_Circle = IconData(0xe93f, fontFamily: _fontFamily); - static const IconData More_Square = IconData(0xe940, fontFamily: _fontFamily); - static const IconData Notification = IconData(0xe941, fontFamily: _fontFamily); - static const IconData Paper_Download = IconData(0xe942, fontFamily: _fontFamily); - static const IconData Paper_Fail = IconData(0xe943, fontFamily: _fontFamily); - static const IconData Paper_Negative = IconData(0xe944, fontFamily: _fontFamily); - static const IconData Paper_Plus = IconData(0xe945, fontFamily: _fontFamily); - static const IconData Paper_Upload = IconData(0xe946, fontFamily: _fontFamily); - static const IconData Paper = IconData(0xe947, fontFamily: _fontFamily); - static const IconData Password = IconData(0xe948, fontFamily: _fontFamily); - static const IconData Play = IconData(0xe949, fontFamily: _fontFamily); - static const IconData Plus = IconData(0xe94a, fontFamily: _fontFamily); - static const IconData Profile = IconData(0xe94b, fontFamily: _fontFamily); - static const IconData Scan = IconData(0xe94c, fontFamily: _fontFamily); - static const IconData Search = IconData(0xe94d, fontFamily: _fontFamily); - static const IconData Send = IconData(0xe94e, fontFamily: _fontFamily); - static const IconData Setting = IconData(0xe94f, fontFamily: _fontFamily); - static const IconData Shield_Done = IconData(0xe950, fontFamily: _fontFamily); - static const IconData Shield_Fail = IconData(0xe951, fontFamily: _fontFamily); - static const IconData Show = IconData(0xe952, fontFamily: _fontFamily); - static const IconData Star = IconData(0xe953, fontFamily: _fontFamily); - static const IconData Swap = IconData(0xe954, fontFamily: _fontFamily); - static const IconData Tick_Square = IconData(0xe955, fontFamily: _fontFamily); - static const IconData Ticket_Star = IconData(0xe956, fontFamily: _fontFamily); - static const IconData Ticket = IconData(0xe957, fontFamily: _fontFamily); - static const IconData Time_Circle = IconData(0xe958, fontFamily: _fontFamily); - static const IconData Time_Square = IconData(0xe959, fontFamily: _fontFamily); - static const IconData Unlock = IconData(0xe95a, fontFamily: _fontFamily); - static const IconData Upload = IconData(0xe95b, fontFamily: _fontFamily); - static const IconData Video = IconData(0xe95c, fontFamily: _fontFamily); - static const IconData Voice_2 = IconData(0xe95d, fontFamily: _fontFamily); - static const IconData Voice = IconData(0xe95e, fontFamily: _fontFamily); - static const IconData Volume_Down = IconData(0xe95f, fontFamily: _fontFamily); - static const IconData Volume_Off = IconData(0xe960, fontFamily: _fontFamily); - static const IconData Volume_Up = IconData(0xe961, fontFamily: _fontFamily); - static const IconData Wallet = IconData(0xe962, fontFamily: _fontFamily); - static const IconData Work = IconData(0xe963, fontFamily: _fontFamily); + static const IconData kUser = IconData(0xe900, fontFamily: _fontFamily); + static const IconData kUser1 = IconData(0xe901, fontFamily: _fontFamily); + static const IconData kActivity = IconData(0xe902, fontFamily: _fontFamily); + static const IconData kAddUser = IconData(0xe903, fontFamily: _fontFamily); + static const IconData kArrowDown2 = IconData(0xe904, fontFamily: _fontFamily); + static const IconData kArrowDown3 = IconData(0xe905, fontFamily: _fontFamily); + static const IconData kArrowDownCircle = IconData(0xe906, fontFamily: _fontFamily); + static const IconData kArrowDownSquare = IconData(0xe907, fontFamily: _fontFamily); + static const IconData kArrowDown = IconData(0xe908, fontFamily: _fontFamily); + static const IconData kArrowLeft2 = IconData(0xe909, fontFamily: _fontFamily); + static const IconData kArrowLeft3 = IconData(0xe90a, fontFamily: _fontFamily); + static const IconData kArrowLeftCircle = IconData(0xe90b, fontFamily: _fontFamily); + static const IconData kArrowLeftSquare = IconData(0xe90c, fontFamily: _fontFamily); + static const IconData kArrowLeft = IconData(0xe90d, fontFamily: _fontFamily); + static const IconData kArrowRight2 = IconData(0xe90e, fontFamily: _fontFamily); + static const IconData kArrowRight3 = IconData(0xe90f, fontFamily: _fontFamily); + static const IconData kArrowRightCircle = IconData(0xe910, fontFamily: _fontFamily); + static const IconData kArrowRightSquare = IconData(0xe911, fontFamily: _fontFamily); + static const IconData kArrowRight = IconData(0xe912, fontFamily: _fontFamily); + static const IconData kArrowUp2 = IconData(0xe913, fontFamily: _fontFamily); + static const IconData kArrowUp3 = IconData(0xe914, fontFamily: _fontFamily); + static const IconData kArrowUpCircle = IconData(0xe915, fontFamily: _fontFamily); + static const IconData kArrowUpSquare = IconData(0xe916, fontFamily: _fontFamily); + static const IconData kArrowUp = IconData(0xe917, fontFamily: _fontFamily); + static const IconData kBag2 = IconData(0xe918, fontFamily: _fontFamily); + static const IconData kBag = IconData(0xe919, fontFamily: _fontFamily); + static const IconData kBookmark = IconData(0xe91a, fontFamily: _fontFamily); + static const IconData kBuy = IconData(0xe91b, fontFamily: _fontFamily); + static const IconData kCalendar = IconData(0xe91c, fontFamily: _fontFamily); + static const IconData kCallMissed = IconData(0xe91d, fontFamily: _fontFamily); + static const IconData kCallSilent = IconData(0xe91e, fontFamily: _fontFamily); + static const IconData kCall = IconData(0xe91f, fontFamily: _fontFamily); + static const IconData kCalling = IconData(0xe920, fontFamily: _fontFamily); + static const IconData kCamera = IconData(0xe921, fontFamily: _fontFamily); + static const IconData kCategory = IconData(0xe922, fontFamily: _fontFamily); + static const IconData kChart = IconData(0xe923, fontFamily: _fontFamily); + static const IconData kChat = IconData(0xe924, fontFamily: _fontFamily); + static const IconData kCloseSquare = IconData(0xe925, fontFamily: _fontFamily); + static const IconData kDanger = IconData(0xe926, fontFamily: _fontFamily); + static const IconData kDelete = IconData(0xe927, fontFamily: _fontFamily); + static const IconData kDiscount = IconData(0xe928, fontFamily: _fontFamily); + static const IconData kDiscovery = IconData(0xe929, fontFamily: _fontFamily); + static const IconData kDocument = IconData(0xe92a, fontFamily: _fontFamily); + static const IconData kDownload = IconData(0xe92b, fontFamily: _fontFamily); + static const IconData kEditSquare = IconData(0xe92c, fontFamily: _fontFamily); + static const IconData kEdit = IconData(0xe92d, fontFamily: _fontFamily); + static const IconData kFilter2 = IconData(0xe92e, fontFamily: _fontFamily); + static const IconData kFilter = IconData(0xe92f, fontFamily: _fontFamily); + static const IconData kFolder = IconData(0xe930, fontFamily: _fontFamily); + static const IconData kGame = IconData(0xe931, fontFamily: _fontFamily); + static const IconData kGraph = IconData(0xe932, fontFamily: _fontFamily); + static const IconData kHeart = IconData(0xe933, fontFamily: _fontFamily); + static const IconData kHide = IconData(0xe934, fontFamily: _fontFamily); + static const IconData kHome = IconData(0xe935, fontFamily: _fontFamily); + static const IconData kImage2 = IconData(0xe936, fontFamily: _fontFamily); + static const IconData kImage = IconData(0xe937, fontFamily: _fontFamily); + static const IconData kInfoCircle = IconData(0xe938, fontFamily: _fontFamily); + static const IconData kInfoSquare = IconData(0xe939, fontFamily: _fontFamily); + static const IconData kLocation = IconData(0xe93a, fontFamily: _fontFamily); + static const IconData kLock = IconData(0xe93b, fontFamily: _fontFamily); + static const IconData kLogin = IconData(0xe93c, fontFamily: _fontFamily); + static const IconData kLogout = IconData(0xe93d, fontFamily: _fontFamily); + static const IconData kMessage = IconData(0xe93e, fontFamily: _fontFamily); + static const IconData kMoreCircle = IconData(0xe93f, fontFamily: _fontFamily); + static const IconData kMoreSquare = IconData(0xe940, fontFamily: _fontFamily); + static const IconData kNotification = IconData(0xe941, fontFamily: _fontFamily); + static const IconData kPaperDownload = IconData(0xe942, fontFamily: _fontFamily); + static const IconData kPaperFail = IconData(0xe943, fontFamily: _fontFamily); + static const IconData kPaperNegative = IconData(0xe944, fontFamily: _fontFamily); + static const IconData kPaperPlus = IconData(0xe945, fontFamily: _fontFamily); + static const IconData kPaperUpload = IconData(0xe946, fontFamily: _fontFamily); + static const IconData kPaper = IconData(0xe947, fontFamily: _fontFamily); + static const IconData kPassword = IconData(0xe948, fontFamily: _fontFamily); + static const IconData kPlay = IconData(0xe949, fontFamily: _fontFamily); + static const IconData kPlus = IconData(0xe94a, fontFamily: _fontFamily); + static const IconData kProfile = IconData(0xe94b, fontFamily: _fontFamily); + static const IconData kScan = IconData(0xe94c, fontFamily: _fontFamily); + static const IconData kSearch = IconData(0xe94d, fontFamily: _fontFamily); + static const IconData kSend = IconData(0xe94e, fontFamily: _fontFamily); + static const IconData kSetting = IconData(0xe94f, fontFamily: _fontFamily); + static const IconData kShieldDone = IconData(0xe950, fontFamily: _fontFamily); + static const IconData kShieldFail = IconData(0xe951, fontFamily: _fontFamily); + static const IconData kShow = IconData(0xe952, fontFamily: _fontFamily); + static const IconData kStar = IconData(0xe953, fontFamily: _fontFamily); + static const IconData kSwap = IconData(0xe954, fontFamily: _fontFamily); + static const IconData kTickSquare = IconData(0xe955, fontFamily: _fontFamily); + static const IconData kTicketStar = IconData(0xe956, fontFamily: _fontFamily); + static const IconData kTicket = IconData(0xe957, fontFamily: _fontFamily); + static const IconData kTimeCircle = IconData(0xe958, fontFamily: _fontFamily); + static const IconData kTimeSquare = IconData(0xe959, fontFamily: _fontFamily); + static const IconData kUnlock = IconData(0xe95a, fontFamily: _fontFamily); + static const IconData kUpload = IconData(0xe95b, fontFamily: _fontFamily); + static const IconData kVideo = IconData(0xe95c, fontFamily: _fontFamily); + static const IconData kVoice2 = IconData(0xe95d, fontFamily: _fontFamily); + static const IconData kVoice = IconData(0xe95e, fontFamily: _fontFamily); + static const IconData kVolumeDown = IconData(0xe95f, fontFamily: _fontFamily); + static const IconData kVolumeOff = IconData(0xe960, fontFamily: _fontFamily); + static const IconData kVolumeUp = IconData(0xe961, fontFamily: _fontFamily); + static const IconData kWallet = IconData(0xe962, fontFamily: _fontFamily); + static const IconData kWork = IconData(0xe963, fontFamily: _fontFamily); } diff --git a/lib/shared/styles/themes.dart b/lib/shared/styles/themes.dart index bc98404..fd4be0c 100644 --- a/lib/shared/styles/themes.dart +++ b/lib/shared/styles/themes.dart @@ -8,20 +8,19 @@ ThemeData darkTheme = ThemeData( scaffoldBackgroundColor: HexColor('333739'), appBarTheme: AppBarTheme( titleSpacing: 20.0, - backwardsCompatibility: false, systemOverlayStyle: SystemUiOverlayStyle( statusBarColor: HexColor('333739'), statusBarIconBrightness: Brightness.light, ), backgroundColor: HexColor('333739'), elevation: 0.0, - titleTextStyle: TextStyle( + titleTextStyle: const TextStyle( fontFamily: 'Jannah', color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.bold, ), - iconTheme: IconThemeData( + iconTheme: const IconThemeData( color: Colors.white, ), ), @@ -32,7 +31,7 @@ ThemeData darkTheme = ThemeData( elevation: 20.0, backgroundColor: HexColor('333739'), ), - textTheme: TextTheme( + textTheme: const TextTheme( bodyText1: TextStyle( fontSize: 18.0, fontWeight: FontWeight.w600, @@ -51,9 +50,8 @@ ThemeData darkTheme = ThemeData( ThemeData lightTheme = ThemeData( primarySwatch: defaultColor, scaffoldBackgroundColor: Colors.white, - appBarTheme: AppBarTheme( + appBarTheme: const AppBarTheme( titleSpacing: 20.0, - backwardsCompatibility: false, systemOverlayStyle: SystemUiOverlayStyle( statusBarColor: Colors.white, statusBarIconBrightness: Brightness.dark, @@ -70,14 +68,14 @@ ThemeData lightTheme = ThemeData( color: Colors.black, ), ), - bottomNavigationBarTheme: BottomNavigationBarThemeData( + bottomNavigationBarTheme: const BottomNavigationBarThemeData( type: BottomNavigationBarType.fixed, selectedItemColor: defaultColor, unselectedItemColor: Colors.grey, elevation: 20.0, backgroundColor: Colors.white, ), - textTheme: TextTheme( + textTheme: const TextTheme( bodyText1: TextStyle( fontSize: 18.0, fontWeight: FontWeight.w600, diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index bac4e99..5271faf 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,6 +6,7 @@ import FlutterMacOS import Foundation import cloud_firestore +import firebase_analytics import firebase_auth import firebase_core import firebase_messaging @@ -15,6 +16,7 @@ import sqflite func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) + FLTFirebaseAnalyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAnalyticsPlugin")) FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin")) diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 17c3631..4df9691 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -327,7 +327,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # debugPrint error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ diff --git a/pubspec.lock b/pubspec.lock index ea59b05..2e33eb4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.2" bloc: dependency: "direct main" description: name: bloc url: "https://pub.dartlang.org" source: hosted - version: "7.0.0" + version: "8.0.3" boolean_selector: dependency: transitive description: @@ -28,21 +28,21 @@ packages: name: carousel_slider url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "4.1.1" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -56,196 +56,182 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "0.14.4" + version: "3.2.1" cloud_firestore_platform_interface: dependency: transitive description: name: cloud_firestore_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "5.5.10" cloud_firestore_web: dependency: transitive description: name: cloud_firestore_web url: "https://pub.dartlang.org" source: hosted - version: "0.2.1+2" + version: "2.6.19" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" - conditional_builder: + version: "1.16.0" + conditional_builder_null_safety: dependency: "direct main" description: - name: conditional_builder + name: conditional_builder_null_safety url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" - convert: + version: "0.0.6" + cross_file: dependency: transitive description: - name: convert + name: cross_file url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.5" + version: "0.3.3+1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.5" dio: dependency: "direct main" description: name: dio url: "https://pub.dartlang.org" source: hosted - version: "3.0.10" + version: "4.0.6" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "2.0.1" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" - firebase: - dependency: transitive - description: - name: firebase - url: "https://pub.dartlang.org" - source: hosted - version: "7.3.3" + version: "6.1.2" firebase_analytics: dependency: "direct main" description: name: firebase_analytics url: "https://pub.dartlang.org" source: hosted - version: "6.3.0" + version: "9.1.12" firebase_analytics_platform_interface: dependency: transitive description: name: firebase_analytics_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "3.1.10" firebase_analytics_web: dependency: transitive description: name: firebase_analytics_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.1" + version: "0.4.0+17" firebase_auth: dependency: "direct main" description: name: firebase_auth url: "https://pub.dartlang.org" source: hosted - version: "0.18.4+1" + version: "3.4.1" firebase_auth_platform_interface: dependency: transitive description: name: firebase_auth_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "6.3.1" firebase_auth_web: dependency: transitive description: name: firebase_auth_web url: "https://pub.dartlang.org" source: hosted - version: "0.3.2+3" + version: "3.3.19" firebase_core: dependency: "direct main" description: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "0.5.3" + version: "1.19.1" firebase_core_platform_interface: dependency: transitive description: name: firebase_core_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "4.4.3" firebase_core_web: dependency: transitive description: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "0.2.1+1" + version: "1.6.6" firebase_messaging: dependency: "direct main" description: name: firebase_messaging url: "https://pub.dartlang.org" source: hosted - version: "8.0.0-dev.11" + version: "11.4.4" firebase_messaging_platform_interface: dependency: transitive description: name: firebase_messaging_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.0-dev.7" + version: "3.5.4" firebase_messaging_web: dependency: transitive description: name: firebase_messaging_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.0-dev.2" + version: "2.4.4" firebase_storage: dependency: "direct main" description: name: firebase_storage url: "https://pub.dartlang.org" source: hosted - version: "5.2.0" + version: "10.3.1" firebase_storage_platform_interface: dependency: transitive description: name: firebase_storage_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "4.1.10" firebase_storage_web: dependency: transitive description: name: firebase_storage_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.1+1" + version: "3.2.19" flutter: dependency: "direct main" description: flutter @@ -257,14 +243,21 @@ packages: name: flutter_bloc url: "https://pub.dartlang.org" source: hosted - version: "7.0.0" + version: "8.0.1" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "1.0.11" + version: "2.0.6" flutter_test: dependency: "direct dev" description: flutter @@ -281,70 +274,105 @@ packages: name: fluttertoast url: "https://pub.dartlang.org" source: hosted - version: "8.0.3" + version: "8.0.9" hexcolor: dependency: "direct main" description: name: hexcolor url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.7" http: dependency: transitive description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.2" + version: "0.13.4" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" + version: "4.0.1" image_picker: dependency: "direct main" description: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.6.7+22" + version: "0.8.5+3" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + url: "https://pub.dartlang.org" + source: hosted + version: "0.8.5+1" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.8" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + url: "https://pub.dartlang.org" + source: hosted + version: "0.8.5+6" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "2.5.0" intl: dependency: "direct main" description: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" js: dependency: transitive description: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" nested: dependency: transitive description: @@ -358,98 +386,91 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.7" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.4" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.0" + version: "2.1.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.1.2" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.1" + version: "4.2.4" provider: dependency: transitive description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" - quiver: - dependency: transitive + version: "6.0.3" + shared_preferences: + dependency: "direct main" description: - name: quiver + name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" - service_worker: + version: "2.0.15" + shared_preferences_android: dependency: transitive description: - name: service_worker + name: shared_preferences_android url: "https://pub.dartlang.org" source: hosted - version: "0.2.4" - shared_preferences: - dependency: "direct main" + version: "2.0.12" + shared_preferences_ios: + dependency: transitive description: - name: shared_preferences + name: shared_preferences_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.1.1" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.1" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.4" shared_preferences_platform_interface: dependency: transitive description: @@ -463,14 +484,14 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.4" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.1" sky_engine: dependency: transitive description: flutter @@ -482,28 +503,28 @@ packages: name: smooth_page_indicator url: "https://pub.dartlang.org" source: hosted - version: "0.2.3" + version: "1.0.0+2" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" sqflite: dependency: "direct main" description: name: sqflite url: "https://pub.dartlang.org" source: hosted - version: "1.3.2+4" + version: "2.0.3" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted - version: "1.0.3+3" + version: "2.2.1+1" stack_trace: dependency: transitive description: @@ -531,7 +552,7 @@ packages: name: synchronized url: "https://pub.dartlang.org" source: hosted - version: "2.2.0+2" + version: "3.0.0+2" term_glyph: dependency: transitive description: @@ -545,42 +566,63 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.9" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" webview_flutter: dependency: "direct main" description: name: webview_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "3.0.4" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.14" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.1" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.1" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.7.0" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.2.0+1" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=2.17.0 <3.0.0" + flutter: ">=3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1fda710..45db81f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ 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.17.5 <3.0.0' dependencies: flutter: @@ -27,33 +27,33 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 - sqflite: ^1.3.0 - intl: - conditional_builder: ^1.0.2 - bloc: ^7.0.0 - flutter_bloc: ^7.0.0 - dio: - hexcolor: ^2.0.3 - shared_preferences: ^2.0.5 - webview_flutter: ^2.0.3 - smooth_page_indicator: ^0.2.0 - fluttertoast: ^8.0.3 - carousel_slider: ^3.0.0 - image_picker: + cupertino_icons: ^1.0.5 + sqflite: ^2.0.3 + intl: ^0.17.0 + conditional_builder_null_safety: ^0.0.6 + bloc: ^8.0.3 + flutter_bloc: ^8.0.1 + dio: ^4.0.6 + hexcolor: ^2.0.7 + shared_preferences: ^2.0.15 + webview_flutter: ^3.0.4 + smooth_page_indicator: ^1.0.0+2 + fluttertoast: ^8.0.9 + carousel_slider: ^4.1.1 + image_picker: ^0.8.5+3 #firebase - firebase_core: ^0.5.3 - firebase_auth: ^0.18.4+1 - firebase_analytics: ^6.3.0 - firebase_storage: ^5.2.0 - firebase_messaging: ^8.0.0-dev.11 - cloud_firestore: ^0.14.3+1 + firebase_core: ^1.19.1 + firebase_auth: ^3.4.1 + firebase_analytics: ^9.1.12 + firebase_storage: ^10.3.1 + firebase_messaging: ^11.4.4 + cloud_firestore: ^3.2.1 dev_dependencies: flutter_test: sdk: flutter - + flutter_lints: ^2.0.1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/test/widget_test.dart b/test/widget_test.dart index a781cca..216b8ba 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -5,10 +5,7 @@ // 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:udemy_flutter/main.dart'; void main() { // testWidgets('Counter increments smoke test', (WidgetTester tester) async {