├── .fvm
├── flutter_sdk
└── fvm_config.json
├── network
├── .fvm
│ ├── flutter_sdk
│ └── fvm_config.json
├── analysis_options.yaml
├── lib
│ ├── network.dart
│ └── src
│ │ ├── utils
│ │ ├── exception_message.dart
│ │ ├── failures.dart
│ │ └── pretty_dio_logger.dart
│ │ └── network
│ │ ├── api_options.dart
│ │ └── rest_client.dart
├── .metadata
├── README.md
├── .gitignore
└── pubspec.yaml
├── ios
├── Flutter
│ ├── Debug.xcconfig
│ ├── Release.xcconfig
│ └── AppFrameworkInfo.plist
├── Runner
│ ├── Runner-Bridging-Header.h
│ ├── Assets.xcassets
│ │ ├── LaunchImage.imageset
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ ├── README.md
│ │ │ └── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-83.5x83.5@2x.png
│ │ │ └── Contents.json
│ ├── AppDelegate.swift
│ ├── Base.lproj
│ │ ├── Main.storyboard
│ │ └── LaunchScreen.storyboard
│ └── Info.plist
├── Runner.xcodeproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ └── IDEWorkspaceChecks.plist
│ ├── xcshareddata
│ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ └── project.pbxproj
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ ├── WorkspaceSettings.xcsettings
│ │ └── IDEWorkspaceChecks.plist
└── .gitignore
├── .gitattributes
├── lib
├── src
│ ├── core
│ │ ├── router
│ │ │ ├── routers.dart
│ │ │ └── router_config.dart
│ │ ├── network
│ │ │ ├── network.dart
│ │ │ ├── request_handler.dart
│ │ │ └── error_model.dart
│ │ └── state
│ │ │ └── base_state.dart
│ └── feature
│ │ ├── category
│ │ ├── data
│ │ │ ├── models
│ │ │ │ └── category_model.dart
│ │ │ ├── data_sources
│ │ │ │ ├── category_data_source.dart
│ │ │ │ └── category_data_source_imp.dart
│ │ │ └── repositories
│ │ │ │ └── category_repository_imp.dart
│ │ ├── domain
│ │ │ ├── repositories
│ │ │ │ └── category_repository.dart
│ │ │ └── use_cases
│ │ │ │ └── category_use_case.dart
│ │ └── presentation
│ │ │ ├── provider
│ │ │ └── category_list_provider.dart
│ │ │ └── widgets
│ │ │ └── category_loading_shimmer.dart
│ │ ├── product
│ │ ├── root
│ │ │ ├── data
│ │ │ │ ├── data_sources
│ │ │ │ │ ├── product_data_source.dart
│ │ │ │ │ └── product_data_source_imp.dart
│ │ │ │ ├── repositories
│ │ │ │ │ └── product_repository_imp.dart
│ │ │ │ └── models
│ │ │ │ │ └── product_model.dart
│ │ │ └── domain
│ │ │ │ └── repositories
│ │ │ │ └── product_repository.dart
│ │ ├── products
│ │ │ ├── presentation
│ │ │ │ ├── riverpod
│ │ │ │ │ ├── providers.dart
│ │ │ │ │ └── products_notifier.dart
│ │ │ │ ├── widget
│ │ │ │ │ ├── product_card.dart
│ │ │ │ │ ├── product_list_builder.dart
│ │ │ │ │ ├── category_builder.dart
│ │ │ │ │ └── products_loading_shimmer.dart
│ │ │ │ └── pages
│ │ │ │ │ └── products_list_page.dart
│ │ │ └── domain
│ │ │ │ └── use_cases
│ │ │ │ └── products_use_case.dart
│ │ └── details
│ │ │ ├── domain
│ │ │ └── use_cases
│ │ │ │ └── product_details_use_case.dart
│ │ │ └── presentation
│ │ │ ├── riverpod
│ │ │ └── product_details_notifier.dart
│ │ │ ├── pages
│ │ │ └── product_details_page.dart
│ │ │ └── widgets
│ │ │ ├── product_details_loading_shimmer.dart
│ │ │ └── product_details_builder.dart
│ │ └── authentication
│ │ └── login
│ │ └── presentation
│ │ └── view
│ │ └── login_page.dart
└── main.dart
├── android
├── gradle.properties
├── app
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── drawable
│ │ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable-v21
│ │ │ │ │ └── launch_background.xml
│ │ │ │ ├── values
│ │ │ │ │ └── styles.xml
│ │ │ │ └── values-night
│ │ │ │ │ └── styles.xml
│ │ │ ├── kotlin
│ │ │ │ └── com
│ │ │ │ │ └── momshaddinury
│ │ │ │ │ └── fake_commerce
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── AndroidManifest.xml
│ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ └── profile
│ │ │ └── AndroidManifest.xml
│ └── build.gradle
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── .gitignore
├── settings.gradle
└── build.gradle
├── test
└── widget_test.dart
├── .metadata
├── analysis_options.yaml
├── README.md
├── .gitignore
└── pubspec.yaml
/.fvm/flutter_sdk:
--------------------------------------------------------------------------------
1 | /Users/dinury/fvm/versions/3.10.5
--------------------------------------------------------------------------------
/network/.fvm/flutter_sdk:
--------------------------------------------------------------------------------
1 | /Users/dinury/fvm/versions/3.3.6
--------------------------------------------------------------------------------
/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/.fvm/fvm_config.json:
--------------------------------------------------------------------------------
1 | {
2 | "flutterSdkVersion": "3.10.5",
3 | "flavors": {}
4 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/network/.fvm/fvm_config.json:
--------------------------------------------------------------------------------
1 | {
2 | "flutterSdkVersion": "3.3.6",
3 | "flavors": {}
4 | }
--------------------------------------------------------------------------------
/lib/src/core/router/routers.dart:
--------------------------------------------------------------------------------
1 | enum Routes {
2 | productList,
3 | productDetails,
4 | login,
5 | }
6 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/network/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:flutter_lints/flutter.yaml
2 |
3 | # Additional information about this file can be found at
4 | # https://dart.dev/guides/language/analysis-options
5 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/momshaddinury/fake_commerce/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/network/lib/network.dart:
--------------------------------------------------------------------------------
1 | library network;
2 |
3 | export 'package:network/src/network/rest_client.dart';
4 | export 'package:network/src/utils/failures.dart';
5 | export 'package:network/src/utils/pretty_dio_logger.dart';
6 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/com/momshaddinury/fake_commerce/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.momshaddinury.fake_commerce
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/network/lib/src/utils/exception_message.dart:
--------------------------------------------------------------------------------
1 | class ExceptionMessage {
2 | static const String defaultError =
3 | 'Something went wrong. Please, try again later.';
4 | static const String couldNotConnectToServer = 'Couldn\'t connect to server';
5 | }
6 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
6 |
--------------------------------------------------------------------------------
/lib/src/feature/category/data/models/category_model.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | List categoryModelFromJson(List item) =>
4 | List.from(item.map((x) => x));
5 |
6 | String categoryModelToJson(List data) =>
7 | json.encode(List.from(data.map((x) => x)));
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/src/core/network/network.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_riverpod/flutter_riverpod.dart';
2 | import 'package:network/network.dart';
3 |
4 | final dioProvider = Provider(
5 | (ref) {
6 | return RestClient(
7 | baseUrl: 'https://fakestoreapi.com/',
8 | token: '',
9 | );
10 | },
11 | );
12 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/network/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 6928314d505d2bb4777be05e45d7808a5aa91d2a
8 | channel: stable
9 |
10 | project_type: module
11 |
--------------------------------------------------------------------------------
/network/README.md:
--------------------------------------------------------------------------------
1 | # network
2 |
3 | A new Flutter project.
4 |
5 | ## Getting Started
6 |
7 | For help getting started with Flutter development, view the online
8 | [documentation](https://flutter.dev/).
9 |
10 | For instructions integrating Flutter modules to your existing applications,
11 | see the [add-to-app documentation](https://flutter.dev/docs/development/add-to-app).
12 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/src/core/state/base_state.dart:
--------------------------------------------------------------------------------
1 | abstract class BaseState {
2 | const BaseState();
3 | }
4 |
5 | class InitialState extends BaseState {}
6 |
7 | class LoadingState extends BaseState {
8 | const LoadingState({this.data});
9 |
10 | final T? data;
11 | }
12 |
13 | class SuccessState extends BaseState {
14 | const SuccessState({this.data});
15 |
16 | final T? data;
17 | }
18 |
19 | class ErrorState extends BaseState {
20 | const ErrorState({this.data});
21 |
22 | final T? data;
23 | }
24 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4 | def properties = new Properties()
5 |
6 | assert localPropertiesFile.exists()
7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
8 |
9 | def flutterSdkPath = properties.getProperty("flutter.sdk")
10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
12 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/lib/src/feature/category/data/data_sources/category_data_source.dart:
--------------------------------------------------------------------------------
1 | import 'package:dio/dio.dart';
2 | import 'package:fake_commerce/src/core/network/network.dart';
3 | import 'package:flutter_riverpod/flutter_riverpod.dart';
4 |
5 | import 'category_data_source_imp.dart';
6 |
7 | final categoryDataSourceProvider = Provider(
8 | (ref) => CategoryDataSourceImpl(
9 | client: ref.watch(dioProvider),
10 | ),
11 | );
12 |
13 | abstract class CategoryDataSource {
14 | Future categories();
15 | }
16 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/src/feature/category/data/data_sources/category_data_source_imp.dart:
--------------------------------------------------------------------------------
1 | import 'package:dio/dio.dart';
2 | import 'package:network/network.dart';
3 |
4 | import 'category_data_source.dart';
5 |
6 | class CategoryDataSourceImpl implements CategoryDataSource {
7 | CategoryDataSourceImpl({
8 | required this.client,
9 | });
10 |
11 | final RestClient client;
12 |
13 | @override
14 | Future categories() async {
15 | final response = await client.get(
16 | APIType.public,
17 | 'products/categories',
18 | );
19 | return response;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/src/feature/product/root/data/data_sources/product_data_source.dart:
--------------------------------------------------------------------------------
1 | import 'package:dio/dio.dart';
2 | import 'package:fake_commerce/src/core/network/network.dart';
3 | import 'package:flutter_riverpod/flutter_riverpod.dart';
4 |
5 | import 'product_data_source_imp.dart';
6 |
7 | final productDataSourceProvider = Provider(
8 | (ref) {
9 | return ProductDataSourceImpl(
10 | client: ref.read(dioProvider),
11 | );
12 | },
13 | );
14 |
15 | abstract class ProductDataSource {
16 | Future fetchProductList();
17 |
18 | Future fetchProduct(int id);
19 | }
20 |
--------------------------------------------------------------------------------
/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_riverpod/flutter_riverpod.dart';
3 |
4 | import 'src/core/router/router_config.dart';
5 |
6 | void main() {
7 | runApp(const ProviderScope(child: MyApp()));
8 | }
9 |
10 | class MyApp extends ConsumerWidget {
11 | const MyApp({super.key});
12 |
13 | @override
14 | Widget build(BuildContext context, ref) {
15 | return MaterialApp.router(
16 | title: 'Fake Commerce',
17 | routerConfig: ref.read(goRouterProvider),
18 | theme: ThemeData(
19 | primarySwatch: Colors.blue,
20 | ),
21 | );
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/network/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | .idea/
8 | .vagrant/
9 | .sconsign.dblite
10 | .svn/
11 |
12 | migrate_working_dir/
13 |
14 | *.swp
15 | profile
16 |
17 | DerivedData/
18 |
19 | .generated/
20 |
21 | *.pbxuser
22 | *.mode1v3
23 | *.mode2v3
24 | *.perspectivev3
25 |
26 | !default.pbxuser
27 | !default.mode1v3
28 | !default.mode2v3
29 | !default.perspectivev3
30 |
31 | xcuserdata
32 |
33 | *.moved-aside
34 |
35 | *.pyc
36 | *sync/
37 | Icon?
38 | .tags*
39 |
40 | build/
41 | .android/
42 | .ios/
43 | .flutter-plugins
44 | .flutter-plugins-dependencies
45 |
46 | # Symbolication related
47 | app.*.symbols
48 |
49 | # Obfuscation related
50 | app.*.map.json
51 |
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/lib/src/feature/product/root/data/data_sources/product_data_source_imp.dart:
--------------------------------------------------------------------------------
1 | import 'package:dio/dio.dart';
2 | import 'package:network/network.dart';
3 |
4 | import 'product_data_source.dart';
5 |
6 | class ProductDataSourceImpl implements ProductDataSource {
7 | ProductDataSourceImpl({
8 | required this.client,
9 | });
10 |
11 | final RestClient client;
12 |
13 | @override
14 | Future fetchProductList() async {
15 | return await client.get(
16 | APIType.public,
17 | 'products',
18 | );
19 | }
20 |
21 | @override
22 | Future fetchProduct(int id) async {
23 | return await client.get(
24 | APIType.public,
25 | 'products/$id',
26 | );
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/src/feature/category/domain/repositories/category_repository.dart:
--------------------------------------------------------------------------------
1 | import 'package:dartz/dartz.dart';
2 | import 'package:fake_commerce/src/core/network/error_model.dart';
3 | import 'package:fake_commerce/src/feature/category/data/data_sources/category_data_source.dart';
4 | import 'package:fake_commerce/src/feature/category/data/repositories/category_repository_imp.dart';
5 | import 'package:flutter_riverpod/flutter_riverpod.dart';
6 |
7 | final categoryRepositoryProvider = Provider(
8 | (ref) => CategoryRepositoryImpl(
9 | dataSource: ref.watch(categoryDataSourceProvider),
10 | ),
11 | );
12 |
13 | abstract class CategoryRepository {
14 | Future>> categories();
15 | }
16 |
--------------------------------------------------------------------------------
/lib/src/feature/category/presentation/provider/category_list_provider.dart:
--------------------------------------------------------------------------------
1 | import 'dart:developer';
2 |
3 | import 'package:fake_commerce/src/feature/category/domain/use_cases/category_use_case.dart';
4 | import 'package:flutter_riverpod/flutter_riverpod.dart';
5 |
6 | final selectedCategoryProvider = StateProvider((ref) => '');
7 |
8 | final categoriesProvider = FutureProvider>(
9 | (ref) async {
10 | final categories = await ref.watch(categoryUseCaseProvider).categories();
11 |
12 | return categories.fold(
13 | (l) {
14 | log(
15 | 'categoriesProvider',
16 | error: l,
17 | );
18 | return [];
19 | },
20 | (r) => r,
21 | );
22 | },
23 | );
24 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.7.10'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.2.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | tasks.register("clean", Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/lib/src/feature/category/domain/use_cases/category_use_case.dart:
--------------------------------------------------------------------------------
1 | import 'package:dartz/dartz.dart';
2 | import 'package:fake_commerce/src/core/network/error_model.dart';
3 | import 'package:fake_commerce/src/feature/category/domain/repositories/category_repository.dart';
4 | import 'package:flutter_riverpod/flutter_riverpod.dart';
5 |
6 | final categoryUseCaseProvider = Provider(
7 | (ref) => CategoryUseCase(
8 | ref.watch(categoryRepositoryProvider),
9 | ),
10 | );
11 |
12 | class CategoryUseCase {
13 | CategoryUseCase(this._categoryRepository);
14 |
15 | final CategoryRepository _categoryRepository;
16 |
17 | Future>> categories() async {
18 | return await _categoryRepository.categories();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/lib/src/feature/product/products/presentation/riverpod/providers.dart:
--------------------------------------------------------------------------------
1 | import 'package:fake_commerce/src/core/state/base_state.dart';
2 | import 'package:fake_commerce/src/feature/product/products/domain/use_cases/products_use_case.dart';
3 | import 'package:fake_commerce/src/feature/product/root/data/models/product_model.dart';
4 | import 'package:flutter_riverpod/flutter_riverpod.dart';
5 |
6 | import 'products_notifier.dart';
7 |
8 | final productsProvider = StateNotifierProvider(
9 | (ref) {
10 | return ProductsNotifier(
11 | ref: ref,
12 | useCase: ref.watch(productsUseCaseProvider),
13 | );
14 | },
15 | );
16 |
17 | final productDataProvider = Provider(
18 | (ref) => throw UnimplementedError(),
19 | );
20 |
--------------------------------------------------------------------------------
/lib/src/core/network/request_handler.dart:
--------------------------------------------------------------------------------
1 | import 'dart:developer';
2 |
3 | import 'package:dartz/dartz.dart';
4 | import 'package:dio/dio.dart';
5 | import 'package:fake_commerce/src/core/network/error_model.dart';
6 | import 'package:network/network.dart';
7 |
8 | extension FutureResponseExtension on Future {
9 | Future> guard(Function(dynamic) parse) async {
10 | try {
11 | final response = await this;
12 |
13 | return Right(parse(response.data));
14 | } on Failure catch (e, stacktrace) {
15 | log(
16 | runtimeType.toString(),
17 | error: {},
18 | stackTrace: stacktrace,
19 | );
20 | ErrorModel errorModel = ErrorModel.fromJson(e.error);
21 |
22 | return Left(errorModel);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/network/lib/src/network/api_options.dart:
--------------------------------------------------------------------------------
1 | part of 'rest_client.dart';
2 |
3 | //PUBLIC => Generic API url without access token
4 | //PROTECTED => Generic API url with access token
5 | enum APIType { public, protected }
6 |
7 | abstract class ApiOptions {
8 | Options options = Options();
9 | }
10 |
11 | class PublicApiOptions extends ApiOptions {
12 | PublicApiOptions() {
13 | super.options.headers = {
14 | 'Accept': 'application/json',
15 | 'Content-type': 'application/json',
16 | };
17 | }
18 | }
19 |
20 | class ProtectedApiOptions extends ApiOptions {
21 | ProtectedApiOptions(String apiToken) {
22 | super.options.headers = {
23 | 'Accept': 'application/json',
24 | 'Content-Type': 'application/json',
25 | 'Authorization': 'Bearer $apiToken',
26 | };
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/src/feature/product/products/domain/use_cases/products_use_case.dart:
--------------------------------------------------------------------------------
1 | import 'package:dartz/dartz.dart';
2 | import 'package:fake_commerce/src/core/network/error_model.dart';
3 | import 'package:fake_commerce/src/feature/product/root/data/models/product_model.dart';
4 | import 'package:fake_commerce/src/feature/product/root/domain/repositories/product_repository.dart';
5 | import 'package:flutter_riverpod/flutter_riverpod.dart';
6 |
7 | final productsUseCaseProvider = Provider(
8 | (ref) {
9 | return ProductsUseCase(
10 | ref.read(productRepositoryProvider),
11 | );
12 | },
13 | );
14 |
15 | class ProductsUseCase {
16 | ProductsUseCase(this._repository);
17 |
18 | final ProductRepository _repository;
19 |
20 | Future>> productList() async {
21 | return await _repository.productList();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 11.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/lib/src/feature/product/root/domain/repositories/product_repository.dart:
--------------------------------------------------------------------------------
1 | import 'package:dartz/dartz.dart';
2 | import 'package:fake_commerce/src/core/network/error_model.dart';
3 | import 'package:fake_commerce/src/feature/product/root/data/data_sources/product_data_source.dart';
4 | import 'package:fake_commerce/src/feature/product/root/data/models/product_model.dart';
5 | import 'package:fake_commerce/src/feature/product/root/data/repositories/product_repository_imp.dart';
6 | import 'package:flutter_riverpod/flutter_riverpod.dart';
7 |
8 | final productRepositoryProvider = Provider(
9 | (ref) {
10 | return ProductRepositoryImpl(
11 | dataSource: ref.read(productDataSourceProvider),
12 | );
13 | },
14 | );
15 |
16 | abstract class ProductRepository {
17 | Future>> productList();
18 |
19 | Future> product(int id);
20 | }
21 |
--------------------------------------------------------------------------------
/lib/src/feature/product/details/domain/use_cases/product_details_use_case.dart:
--------------------------------------------------------------------------------
1 | import 'package:dartz/dartz.dart';
2 | import 'package:fake_commerce/src/core/network/error_model.dart';
3 | import 'package:fake_commerce/src/feature/product/root/data/models/product_model.dart';
4 | import 'package:fake_commerce/src/feature/product/root/domain/repositories/product_repository.dart';
5 | import 'package:flutter_riverpod/flutter_riverpod.dart';
6 |
7 | final productDetailsUseCaseProvider = Provider(
8 | (ref) {
9 | final repository = ref.watch(productRepositoryProvider);
10 | return ProductDetailsUseCase(repository);
11 | },
12 | );
13 |
14 | class ProductDetailsUseCase {
15 | ProductDetailsUseCase(this._repository);
16 |
17 | final ProductRepository _repository;
18 |
19 | Future> product(int id) async {
20 | return await _repository.product(id);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/lib/src/feature/category/data/repositories/category_repository_imp.dart:
--------------------------------------------------------------------------------
1 | import 'package:dartz/dartz.dart';
2 | import 'package:fake_commerce/src/core/network/error_model.dart';
3 | import 'package:fake_commerce/src/core/network/request_handler.dart';
4 | import 'package:fake_commerce/src/feature/category/data/data_sources/category_data_source.dart';
5 | import 'package:fake_commerce/src/feature/category/data/models/category_model.dart';
6 | import 'package:fake_commerce/src/feature/category/domain/repositories/category_repository.dart';
7 |
8 | class CategoryRepositoryImpl implements CategoryRepository {
9 | CategoryRepositoryImpl({
10 | required this.dataSource,
11 | });
12 |
13 | final CategoryDataSource dataSource;
14 |
15 | @override
16 | Future>> categories() async {
17 | return await dataSource.categories().guard((data) {
18 | return categoryModelFromJson(data);
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/src/core/network/error_model.dart:
--------------------------------------------------------------------------------
1 | class ErrorResponseModel {
2 | ErrorResponseModel({
3 | this.error,
4 | });
5 |
6 | ErrorModel? error;
7 |
8 | factory ErrorResponseModel.fromJson(Map json) {
9 | return ErrorResponseModel(
10 | error: json["error"] == null ? null : ErrorModel.fromJson(json["error"]),
11 | );
12 | }
13 | }
14 |
15 | class ErrorModel {
16 | ErrorModel({
17 | this.message = "Something went wrong! Please try again later.",
18 | this.code = "500",
19 | this.stack,
20 | });
21 |
22 | String? message;
23 | String? code;
24 | String? stack;
25 |
26 | factory ErrorModel.fromJson(Map json) {
27 | return ErrorModel(
28 | message: json["message"],
29 | code: json["code"],
30 | stack: json["stack"],
31 | );
32 | }
33 |
34 | Map toJson() {
35 | return {
36 | "message": message,
37 | "code": code,
38 | "stack": stack,
39 | };
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/feature/product/details/presentation/riverpod/product_details_notifier.dart:
--------------------------------------------------------------------------------
1 | import 'dart:developer';
2 |
3 | import 'package:fake_commerce/src/feature/product/details/domain/use_cases/product_details_use_case.dart';
4 | import 'package:fake_commerce/src/feature/product/root/data/models/product_model.dart';
5 | import 'package:flutter_riverpod/flutter_riverpod.dart';
6 |
7 | final productDetailsProvider =
8 | FutureProvider.autoDispose.family(
9 | (ref, value) async {
10 | try {
11 | final result =
12 | await ref.read(productDetailsUseCaseProvider).product(value);
13 |
14 | return result.fold(
15 | (l) => null,
16 | (r) {
17 | ref.keepAlive();
18 | return r;
19 | },
20 | );
21 | } catch (e, stackTrace) {
22 | log(
23 | 'productDetailsProvider.futureProvider',
24 | error: e,
25 | stackTrace: stackTrace,
26 | );
27 | }
28 |
29 | return null;
30 | },
31 | );
32 |
--------------------------------------------------------------------------------
/lib/src/feature/product/products/presentation/widget/product_card.dart:
--------------------------------------------------------------------------------
1 | part of '../pages/products_list_page.dart';
2 |
3 | class _ProductCard extends ConsumerWidget {
4 | const _ProductCard({Key? key}) : super(key: key);
5 |
6 | @override
7 | Widget build(BuildContext context, ref) {
8 | ProductModel data = ref.read(productDataProvider);
9 |
10 | return ListTile(
11 | onTap: () {
12 | _navigateToProductDetailsPage(context, data.id);
13 | },
14 | leading: Image.network(
15 | data.image,
16 | fit: BoxFit.contain,
17 | height: 100,
18 | width: 100,
19 | ),
20 | title: Text(data.title),
21 | subtitle: Text("\$${data.price}"),
22 | );
23 | }
24 |
25 | void _navigateToProductDetailsPage(
26 | BuildContext context,
27 | int id,
28 | ) {
29 | context.goNamed(
30 | Routes.productDetails.name,
31 | queryParameters: {
32 | 'id': id.toString(),
33 | },
34 | );
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/lib/src/feature/product/products/presentation/widget/product_list_builder.dart:
--------------------------------------------------------------------------------
1 | part of '../pages/products_list_page.dart';
2 |
3 | class _ProductListBuilder extends StatelessWidget {
4 | const _ProductListBuilder({
5 | required this.products,
6 | });
7 |
8 | final List products;
9 |
10 | @override
11 | Widget build(BuildContext context) {
12 | return ListView.separated(
13 | itemCount: products.length,
14 | itemBuilder: (context, index) {
15 | /// This might feel redundant to use a provider to pass
16 | /// data to class, when we can just use prop-drilling to
17 | /// pass the data.
18 | /// But, this is recommended way as you can declare the class
19 | /// as const, which will improve performance.
20 |
21 | return ProviderScope(
22 | overrides: [
23 | productDataProvider.overrideWithValue(
24 | products[index],
25 | ),
26 | ],
27 | child: const _ProductCard(),
28 | );
29 | },
30 | separatorBuilder: (context, index) {
31 | return const Divider();
32 | },
33 | );
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility in the flutter_test package. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:fake_commerce/main.dart';
12 |
13 | void main() {
14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(const MyApp());
17 |
18 | // Verify that our counter starts at 0.
19 | expect(find.text('0'), findsOneWidget);
20 | expect(find.text('1'), findsNothing);
21 |
22 | // Tap the '+' icon and trigger a frame.
23 | await tester.tap(find.byIcon(Icons.add));
24 | await tester.pump();
25 |
26 | // Verify that our counter has incremented.
27 | expect(find.text('0'), findsNothing);
28 | expect(find.text('1'), findsOneWidget);
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled.
5 |
6 | version:
7 | revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
8 | channel: stable
9 |
10 | project_type: app
11 |
12 | # Tracks metadata for the flutter migrate command
13 | migration:
14 | platforms:
15 | - platform: root
16 | create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
17 | base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
18 | - platform: android
19 | create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
20 | base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
21 | - platform: ios
22 | create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
23 | base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
24 |
25 | # User provided section
26 |
27 | # List of Local paths (relative to this file) that should be
28 | # ignored by the migrate tool.
29 | #
30 | # Files that are not part of the templates will be ignored by default.
31 | unmanaged_files:
32 | - 'lib/main.dart'
33 | - 'ios/Runner.xcodeproj/project.pbxproj'
34 |
--------------------------------------------------------------------------------
/lib/src/feature/product/root/data/repositories/product_repository_imp.dart:
--------------------------------------------------------------------------------
1 | import 'package:dartz/dartz.dart';
2 | import 'package:fake_commerce/src/core/network/error_model.dart';
3 | import 'package:fake_commerce/src/core/network/request_handler.dart';
4 | import 'package:fake_commerce/src/feature/product/root/data/data_sources/product_data_source.dart';
5 | import 'package:fake_commerce/src/feature/product/root/data/models/product_model.dart';
6 | import 'package:fake_commerce/src/feature/product/root/domain/repositories/product_repository.dart';
7 |
8 | class ProductRepositoryImpl implements ProductRepository {
9 | ProductRepositoryImpl({required this.dataSource});
10 |
11 | final ProductDataSource dataSource;
12 |
13 | @override
14 | Future>> productList() async {
15 | return await dataSource.fetchProductList().guard(
16 | (data) => (data as List).map((e) {
17 | return ProductModel.fromJson(e);
18 | }).toList(),
19 | );
20 | }
21 |
22 | @override
23 | Future> product(int id) async {
24 | return await dataSource
25 | .fetchProduct(id)
26 | .guard((data) => ProductModel.fromJson(data));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/src/feature/product/root/data/models/product_model.dart:
--------------------------------------------------------------------------------
1 | class ProductModel {
2 | int id;
3 | String title;
4 | double price;
5 | String description;
6 | String category;
7 | String image;
8 | Rating rating;
9 |
10 | ProductModel({
11 | required this.id,
12 | required this.title,
13 | required this.price,
14 | required this.description,
15 | required this.category,
16 | required this.image,
17 | required this.rating,
18 | });
19 |
20 | factory ProductModel.fromJson(Map json) => ProductModel(
21 | id: json["id"],
22 | title: json["title"],
23 | price: json["price"]?.toDouble(),
24 | description: json["description"],
25 | category: json["category"],
26 | image: json["image"],
27 | rating: Rating.fromJson(json["rating"]),
28 | );
29 | }
30 |
31 | class Rating {
32 | double rate;
33 | int count;
34 |
35 | Rating({
36 | required this.rate,
37 | required this.count,
38 | });
39 |
40 | factory Rating.fromJson(Map json) => Rating(
41 | rate: json["rate"]?.toDouble(),
42 | count: json["count"],
43 | );
44 |
45 | Map toJson() => {
46 | "rate": rate,
47 | "count": count,
48 | };
49 | }
50 |
--------------------------------------------------------------------------------
/lib/src/feature/category/presentation/widgets/category_loading_shimmer.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class CategoryLoadingShimmer extends StatelessWidget {
4 | const CategoryLoadingShimmer({Key? key}) : super(key: key);
5 |
6 | @override
7 | Widget build(BuildContext context) {
8 | return Container(
9 | height: 50,
10 | margin: const EdgeInsets.symmetric(
11 | vertical: 16,
12 | ).copyWith(left: 16),
13 | child: ListView.separated(
14 | scrollDirection: Axis.horizontal,
15 | itemCount: 5,
16 | itemBuilder: (context, index) {
17 | return Container(
18 | padding: const EdgeInsets.symmetric(
19 | horizontal: 16,
20 | vertical: 10,
21 | ),
22 | decoration: BoxDecoration(
23 | color: Colors.grey[200],
24 | borderRadius: BorderRadius.circular(8),
25 | ),
26 | child: Center(
27 | child: Container(
28 | height: 50,
29 | width: 100,
30 | color: Colors.grey[200],
31 | ),
32 | ),
33 | );
34 | },
35 | separatorBuilder: (context, index) {
36 | return const SizedBox(width: 8);
37 | },
38 | ),
39 | );
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/feature/product/details/presentation/pages/product_details_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:fake_commerce/src/feature/product/details/presentation/riverpod/product_details_notifier.dart';
2 | import 'package:fake_commerce/src/feature/product/details/presentation/widgets/product_details_loading_shimmer.dart';
3 | import 'package:fake_commerce/src/feature/product/root/data/models/product_model.dart';
4 | import 'package:flutter/material.dart';
5 | import 'package:flutter_riverpod/flutter_riverpod.dart';
6 |
7 | part '../widgets/product_details_builder.dart';
8 |
9 | class ProductDetailsPage extends ConsumerWidget {
10 | const ProductDetailsPage({
11 | Key? key,
12 | required this.productId,
13 | }) : super(key: key);
14 |
15 | final int productId;
16 |
17 | @override
18 | Widget build(BuildContext context, ref) {
19 | final state = ref.watch(productDetailsProvider(productId));
20 |
21 | return Scaffold(
22 | appBar: AppBar(
23 | title: const Text('Product Details'),
24 | ),
25 | body: state.when(
26 | data: (product) {
27 | return _ProductDetailsBuilder(product: product!);
28 | },
29 | loading: () => const ProductDetailsLoadingShimmer(),
30 | error: (error, stackTrace) {
31 | return const Center(child: Text('Error'));
32 | },
33 | ),
34 | );
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/lib/src/feature/product/details/presentation/widgets/product_details_loading_shimmer.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class ProductDetailsLoadingShimmer extends StatelessWidget {
4 | const ProductDetailsLoadingShimmer({Key? key}) : super(key: key);
5 |
6 | @override
7 | Widget build(BuildContext context) {
8 | return Container(
9 | margin: const EdgeInsets.symmetric(
10 | horizontal: 16,
11 | vertical: 8,
12 | ),
13 | child: Column(
14 | crossAxisAlignment: CrossAxisAlignment.start,
15 | children: [
16 | Container(
17 | height: 250,
18 | width: double.infinity,
19 | color: Colors.grey[200],
20 | ),
21 | const Divider(),
22 | Expanded(
23 | child: Column(
24 | crossAxisAlignment: CrossAxisAlignment.start,
25 | children: [
26 | Container(
27 | height: 20,
28 | width: 100,
29 | color: Colors.grey[200],
30 | ),
31 | const SizedBox(height: 8),
32 | Container(
33 | height: 20,
34 | width: 200,
35 | color: Colors.grey[200],
36 | ),
37 | const SizedBox(height: 8),
38 | Container(
39 | height: 20,
40 | width: 100,
41 | color: Colors.grey[200],
42 | ),
43 | ],
44 | ),
45 | ),
46 | ],
47 | ),
48 | );
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/lib/src/feature/authentication/login/presentation/view/login_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:go_router/go_router.dart';
3 |
4 | class LoginPage extends StatefulWidget {
5 | const LoginPage({super.key});
6 |
7 | @override
8 | State createState() => _LoginPageState();
9 | }
10 |
11 | class _LoginPageState extends State {
12 | @override
13 | Widget build(BuildContext context) {
14 | return Scaffold(
15 | appBar: AppBar(title: const Text('Login')),
16 | body: SingleChildScrollView(
17 | padding: EdgeInsets.symmetric(horizontal: 20).copyWith(
18 | bottom: MediaQuery.of(context).viewInsets.bottom,
19 | ),
20 | child: Column(
21 | children: [
22 | SizedBox(height: 200),
23 | const Text('Login Page'),
24 | SizedBox(height: 30),
25 | TextFormField(
26 | decoration: const InputDecoration(
27 | border: OutlineInputBorder(),
28 | labelText: 'Username',
29 | ),
30 | ),
31 | SizedBox(height: 15),
32 | TextFormField(
33 | decoration: const InputDecoration(
34 | border: OutlineInputBorder(),
35 | labelText: 'Password',
36 | ),
37 | ),
38 | SizedBox(height: 30),
39 | ElevatedButton(
40 | onPressed: () {
41 | context.go('/');
42 | },
43 | child: const Text('Login'),
44 | ),
45 | ],
46 | ),
47 | ),
48 | );
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/lib/src/core/router/router_config.dart:
--------------------------------------------------------------------------------
1 | import 'package:fake_commerce/src/core/router/routers.dart';
2 | import 'package:fake_commerce/src/feature/authentication/login/presentation/view/login_page.dart';
3 | import 'package:fake_commerce/src/feature/product/details/presentation/pages/product_details_page.dart';
4 | import 'package:fake_commerce/src/feature/product/products/presentation/pages/products_list_page.dart';
5 | import 'package:flutter/material.dart';
6 | import 'package:flutter_riverpod/flutter_riverpod.dart';
7 | import 'package:go_router/go_router.dart';
8 |
9 | final goRouterProvider = Provider((ref) => _router);
10 |
11 | final GoRouter _router = GoRouter(
12 | routes: [
13 | GoRoute(
14 | path: '/',
15 | name: Routes.productList.name,
16 | pageBuilder: (context, state) {
17 | return MaterialPage(
18 | key: state.pageKey,
19 | child: const ProductListPage(),
20 | );
21 | },
22 | routes: [
23 | GoRoute(
24 | path: Routes.productList.name,
25 | name: Routes.productDetails.name,
26 | pageBuilder: (context, state) {
27 | return MaterialPage(
28 | key: state.pageKey,
29 | child: ProductDetailsPage(
30 | productId: int.parse(state.queryParameters['id']!),
31 | ),
32 | );
33 | },
34 | ),
35 | GoRoute(
36 | path: Routes.login.name,
37 | name: Routes.login.name,
38 | pageBuilder: (context, state) {
39 | return const MaterialPage(
40 | child: LoginPage(),
41 | );
42 | },
43 | ),
44 | ],
45 | ),
46 | ],
47 | );
48 |
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/lib/src/feature/product/products/presentation/widget/category_builder.dart:
--------------------------------------------------------------------------------
1 | part of '../pages/products_list_page.dart';
2 |
3 | class _CategoryBuilder extends ConsumerWidget {
4 | const _CategoryBuilder({
5 | required this.categories,
6 | });
7 |
8 | final List categories;
9 |
10 | @override
11 | Widget build(BuildContext context, ref) {
12 | return Container(
13 | margin: const EdgeInsets.symmetric(
14 | vertical: 16,
15 | ).copyWith(left: 16),
16 | height: 50,
17 | child: ListView.separated(
18 | scrollDirection: Axis.horizontal,
19 | itemCount: categories.length,
20 | itemBuilder: (context, index) {
21 | return InkWell(
22 | onTap: () {
23 | ref.read(selectedCategoryProvider.notifier).state =
24 | categories[index];
25 | },
26 | child: Container(
27 | padding: const EdgeInsets.symmetric(
28 | horizontal: 16,
29 | vertical: 5,
30 | ),
31 | decoration: BoxDecoration(
32 | color: Colors.grey[200],
33 | border: ref.watch(selectedCategoryProvider) == categories[index]
34 | ? Border.all(
35 | color: Colors.blue,
36 | )
37 | : null,
38 | borderRadius: BorderRadius.circular(8),
39 | ),
40 | child: Center(
41 | child: Text(
42 | categories[index].toUpperCase(),
43 | ),
44 | ),
45 | ),
46 | );
47 | },
48 | separatorBuilder: (context, index) {
49 | return const SizedBox(width: 8);
50 | },
51 | ),
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
15 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | Fake Commerce
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | fake_commerce
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | $(FLUTTER_BUILD_NUMBER)
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UIViewControllerBasedStatusBarAppearance
45 |
46 | CADisableMinimumFrameDurationOnPhone
47 |
48 | UIApplicationSupportsIndirectInputEvents
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/lib/src/feature/product/products/presentation/widget/products_loading_shimmer.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class ProductsLoadingShimmer extends StatelessWidget {
4 | const ProductsLoadingShimmer({Key? key}) : super(key: key);
5 |
6 | @override
7 | Widget build(BuildContext context) {
8 | return ListView.separated(
9 | scrollDirection: Axis.vertical,
10 | itemCount: 5,
11 | itemBuilder: (context, index) {
12 | return Container(
13 | margin: const EdgeInsets.symmetric(
14 | horizontal: 16,
15 | vertical: 8,
16 | ),
17 | child: Row(
18 | children: [
19 | Container(
20 | height: 100,
21 | width: 100,
22 | color: Colors.grey[200],
23 | ),
24 | const SizedBox(width: 16),
25 | Expanded(
26 | child: Column(
27 | crossAxisAlignment: CrossAxisAlignment.start,
28 | children: [
29 | Container(
30 | height: 20,
31 | width: 100,
32 | color: Colors.grey[200],
33 | ),
34 | const SizedBox(height: 8),
35 | Container(
36 | height: 20,
37 | width: 200,
38 | color: Colors.grey[200],
39 | ),
40 | const SizedBox(height: 8),
41 | Container(
42 | height: 20,
43 | width: 100,
44 | color: Colors.grey[200],
45 | ),
46 | ],
47 | ),
48 | ),
49 | ],
50 | ),
51 | );
52 | },
53 | separatorBuilder: (context, index) {
54 | return const SizedBox(width: 8);
55 | },
56 | );
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/lib/src/feature/product/details/presentation/widgets/product_details_builder.dart:
--------------------------------------------------------------------------------
1 | part of '../pages/product_details_page.dart';
2 |
3 | class _ProductDetailsBuilder extends ConsumerWidget {
4 | const _ProductDetailsBuilder({
5 | required this.product,
6 | });
7 |
8 | final ProductModel product;
9 |
10 | @override
11 | Widget build(BuildContext context, ref) {
12 | return RefreshIndicator(
13 | onRefresh: () => ref.refresh(productDetailsProvider(product.id).future),
14 | child: ListView(
15 | physics: const AlwaysScrollableScrollPhysics(),
16 | children: [
17 | const SizedBox(height: 16),
18 | Image.network(
19 | product.image,
20 | fit: BoxFit.contain,
21 | width: double.infinity,
22 | height: 250,
23 | ),
24 | const Divider(),
25 | Padding(
26 | padding: const EdgeInsets.symmetric(
27 | horizontal: 16,
28 | ),
29 | child: Column(
30 | mainAxisSize: MainAxisSize.min,
31 | crossAxisAlignment: CrossAxisAlignment.start,
32 | children: [
33 | Text(
34 | product.title,
35 | style: Theme.of(context).textTheme.titleLarge,
36 | ),
37 | const SizedBox(height: 8),
38 | Text(
39 | "\$${product.price}",
40 | style: Theme.of(context).textTheme.bodyMedium,
41 | ),
42 | const SizedBox(height: 4),
43 | Text(
44 | "Category: ${product.category.toUpperCase()}",
45 | style: Theme.of(context).textTheme.labelLarge,
46 | ),
47 | const SizedBox(height: 8),
48 | Text(
49 | product.description,
50 | style: Theme.of(context).textTheme.bodyLarge,
51 | ),
52 | const SizedBox(height: 8),
53 | ],
54 | ),
55 | ),
56 | ],
57 | ),
58 | );
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/lib/src/feature/product/products/presentation/riverpod/products_notifier.dart:
--------------------------------------------------------------------------------
1 | import 'dart:developer';
2 |
3 | import 'package:fake_commerce/src/core/state/base_state.dart';
4 | import 'package:fake_commerce/src/feature/category/presentation/provider/category_list_provider.dart';
5 | import 'package:fake_commerce/src/feature/product/products/domain/use_cases/products_use_case.dart';
6 | import 'package:fake_commerce/src/feature/product/root/data/models/product_model.dart';
7 | import 'package:flutter_riverpod/flutter_riverpod.dart';
8 |
9 | class ProductsNotifier extends StateNotifier {
10 | ProductsNotifier({
11 | required this.ref,
12 | required this.useCase,
13 | }) : super(InitialState()) {
14 | ref.listen(selectedCategoryProvider, (previous, next) {
15 | productList(hasFilter: previous != next);
16 | });
17 | }
18 |
19 | final Ref ref;
20 | final ProductsUseCase useCase;
21 |
22 | List _products = [];
23 |
24 | Future productList({bool hasFilter = false}) async {
25 | if (hasFilter) {
26 | if (state is SuccessState) {
27 | String category = ref.read(selectedCategoryProvider);
28 |
29 | if (category.isNotEmpty) {
30 | List filteredProducts = _products
31 | .where((element) => element.category == category.toLowerCase())
32 | .toList();
33 |
34 | state = const LoadingState();
35 | await Future.delayed(const Duration(milliseconds: 100));
36 |
37 | state = SuccessState(
38 | data: filteredProducts.isEmpty ? _products : filteredProducts,
39 | );
40 | }
41 |
42 | return;
43 | }
44 | }
45 |
46 | state = const LoadingState();
47 | try {
48 | final result = await useCase.productList();
49 | result.fold(
50 | (l) {
51 | log(
52 | 'ProductsNotifier.productList',
53 | error: l,
54 | );
55 | return state = ErrorState(data: l.toString());
56 | },
57 | (r) {
58 | _products = r;
59 | return state = SuccessState(data: r);
60 | },
61 | );
62 | } catch (e, stacktrace) {
63 | log(
64 | 'ProductsNotifier.productList',
65 | error: e,
66 | stackTrace: stacktrace,
67 | );
68 | state = ErrorState(data: e.toString());
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion flutter.compileSdkVersion
30 | ndkVersion flutter.ndkVersion
31 |
32 | compileOptions {
33 | sourceCompatibility JavaVersion.VERSION_1_8
34 | targetCompatibility JavaVersion.VERSION_1_8
35 | }
36 |
37 | kotlinOptions {
38 | jvmTarget = '1.8'
39 | }
40 |
41 | sourceSets {
42 | main.java.srcDirs += 'src/main/kotlin'
43 | }
44 |
45 | defaultConfig {
46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
47 | applicationId "com.momshaddinury.fake_commerce"
48 | // You can update the following values to match your application needs.
49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
50 | minSdkVersion flutter.minSdkVersion
51 | targetSdkVersion flutter.targetSdkVersion
52 | versionCode flutterVersionCode.toInteger()
53 | versionName flutterVersionName
54 | }
55 |
56 | buildTypes {
57 | release {
58 | // TODO: Add your own signing config for the release build.
59 | // Signing with the debug keys for now, so `flutter run --release` works.
60 | signingConfig signingConfigs.debug
61 | }
62 | }
63 | }
64 |
65 | flutter {
66 | source '../..'
67 | }
68 |
69 | dependencies {
70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
71 | }
72 |
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # README
2 |
3 | ## Overview
4 | This project is a Flutter application that uses Riverpod for state management and dependency injection, Clean Architecture for the project structure, Fake Store API for data retrieval, and Dio for network communication.
5 |
6 | ## Requirements
7 | To run this project, you need to have the following software installed on your machine:
8 | - Flutter (3.7.12 - Stable)
9 | - Dart ('>=2.19.6 <3.0.0')
10 |
11 | ## Installation
12 | 1. Clone the repository to your local machine.
13 | 2. Open the project in your preferred IDE.
14 | 3. Run `flutter pub get` to install the required dependencies.
15 |
16 | ## Usage
17 | You can run the project on either an emulator or a physical device using the command `flutter run`.
18 |
19 | ## Project Structure
20 | The project uses Clean Architecture, which separates the code into layers: Presentation, Domain, and Data. Each layer has its own responsibility and is independent of the other layers.
21 |
22 | The project structure is as follows:
23 |
24 | ```
25 | .
26 | └── lib/
27 | ├── src/
28 | │ ├── core/
29 | │ │ ├── base
30 | │ │ └── network
31 | │ └── feature/
32 | │ └── product/
33 | │ ├── details/
34 | │ │ ├── data/
35 | │ │ │ └── models
36 | │ │ ├── domain/
37 | │ │ │ └── use_cases
38 | │ │ └── presentation/
39 | │ │ ├── pages
40 | │ │ └── riverpod
41 | │ ├── products/
42 | │ │ ├── data/
43 | │ │ │ └── models
44 | │ │ ├── domain/
45 | │ │ │ ├── repositories
46 | │ │ │ └── use_cases
47 | │ │ └── presentation/
48 | │ │ ├── pages
49 | │ │ └── riverpod
50 | │ └── root/
51 | │ └── data/
52 | │ ├── data_sources
53 | │ └── repositories
54 | └── main.dart
55 | ```
56 | ## Dependencies
57 | - flutter_riverpod: 2.3.6
58 | - dio: 5.1.1
59 | - dartz: 0.10.1
60 |
61 | ## Feature
62 | - Fetching all products and categories
63 | - Filtering fetched products by category locally
64 | - Fetching product details and caching the response
65 | - Improving performance of ListView by using *overrideWithValue* and passing const widget
66 | - Navigation using GoRouter
67 |
68 | ## Dependency Injection, State Management & Caching
69 | The project uses Riverpod for both state management and dependency injection. It allows for easy management of dependencies and makes it easier to test the code. By combining ```FutureProvider.autoDispose``` with ```keepAlive``` caching is also acheieved.
70 |
71 | ## Network Communication
72 | The project uses Dio for network communication, which is a powerful HTTP client for Dart. It makes it easy to make network requests and handle responses.
73 |
74 | ## Data Retrieval
75 | The project uses the Fake Store API for data retrieval. This is a fake e-commerce API that provides product data that can be used for testing and demonstration purposes.
76 |
77 | ## Conclusion
78 | This project is an example of how to use Flutter, Riverpod, Clean Architecture, Fake Store API, and Dio together to create a robust and maintainable application.
79 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.lock
4 | *.log
5 | *.pyc
6 | *.swp
7 | .DS_Store
8 | .atom/
9 | .buildlog/
10 | .history
11 | .svn/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # Visual Studio Code related
20 | .classpath
21 | .project
22 | .settings/
23 | .vscode/*
24 |
25 | # Flutter repo-specific
26 | /bin/cache/
27 | /bin/internal/bootstrap.bat
28 | /bin/internal/bootstrap.sh
29 | /bin/mingit/
30 | /dev/benchmarks/mega_gallery/
31 | /dev/bots/.recipe_deps
32 | /dev/bots/android_tools/
33 | /dev/devicelab/ABresults*.json
34 | /dev/docs/doc/
35 | /dev/docs/flutter.docs.zip
36 | /dev/docs/lib/
37 | /dev/docs/pubspec.yaml
38 | /dev/integration_tests/**/xcuserdata
39 | /dev/integration_tests/**/Pods
40 | /packages/flutter/coverage/
41 | version
42 | analysis_benchmark.json
43 |
44 | # packages file containing multi-root paths
45 | .packages.generated
46 |
47 | # Flutter/Dart/Pub related
48 | **/doc/api/
49 | .dart_tool/
50 | .flutter-plugins
51 | .flutter-plugins-dependencies
52 | **/generated_plugin_registrant.dart
53 | .packages
54 | .pub-preload-cache/
55 | .pub/
56 | build/
57 | flutter_*.png
58 | linked_*.ds
59 | unlinked.ds
60 | unlinked_spec.ds
61 |
62 | # Android related
63 | **/android/**/gradle-wrapper.jar
64 | .gradle/
65 | **/android/captures/
66 | **/android/gradlew
67 | **/android/gradlew.bat
68 | **/android/local.properties
69 | **/android/**/GeneratedPluginRegistrant.java
70 | **/android/key.properties
71 | *.jks
72 |
73 | # iOS/XCode related
74 | **/ios/**/*.mode1v3
75 | **/ios/**/*.mode2v3
76 | **/ios/**/*.moved-aside
77 | **/ios/**/*.pbxuser
78 | **/ios/**/*.perspectivev3
79 | **/ios/**/*sync/
80 | **/ios/**/.sconsign.dblite
81 | **/ios/**/.tags*
82 | **/ios/**/.vagrant/
83 | **/ios/**/DerivedData/
84 | **/ios/**/Icon?
85 | **/ios/**/Pods/
86 | **/ios/**/.symlinks/
87 | **/ios/**/profile
88 | **/ios/**/xcuserdata
89 | **/ios/.generated/
90 | **/ios/Flutter/.last_build_id
91 | **/ios/Flutter/App.framework
92 | **/ios/Flutter/Flutter.framework
93 | **/ios/Flutter/Flutter.podspec
94 | **/ios/Flutter/Generated.xcconfig
95 | **/ios/Flutter/ephemeral
96 | **/ios/Flutter/app.flx
97 | **/ios/Flutter/app.zip
98 | **/ios/Flutter/flutter_assets/
99 | **/ios/Flutter/flutter_export_environment.sh
100 | **/ios/ServiceDefinitions.json
101 | **/ios/Runner/GeneratedPluginRegistrant.*
102 |
103 | # macOS
104 | **/Flutter/ephemeral/
105 | **/Pods/
106 | **/macos/Flutter/GeneratedPluginRegistrant.swift
107 | **/macos/Flutter/ephemeral
108 | **/xcuserdata/
109 |
110 | # Windows
111 | **/windows/flutter/generated_plugin_registrant.cc
112 | **/windows/flutter/generated_plugin_registrant.h
113 | **/windows/flutter/generated_plugins.cmake
114 |
115 | # Linux
116 | **/linux/flutter/generated_plugin_registrant.cc
117 | **/linux/flutter/generated_plugin_registrant.h
118 | **/linux/flutter/generated_plugins.cmake
119 |
120 | # Coverage
121 | coverage/
122 |
123 | # Symbols
124 | app.*.symbols
125 |
126 | # Exceptions to above rules.
127 | !**/ios/**/default.mode1v3
128 | !**/ios/**/default.mode2v3
129 | !**/ios/**/default.pbxuser
130 | !**/ios/**/default.perspectivev3
131 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
132 | !/dev/ci/**/Gemfile.lock
133 | !.vscode/settings.json
--------------------------------------------------------------------------------
/lib/src/feature/product/products/presentation/pages/products_list_page.dart:
--------------------------------------------------------------------------------
1 | import 'dart:developer';
2 |
3 | import 'package:fake_commerce/src/core/router/routers.dart';
4 | import 'package:fake_commerce/src/core/state/base_state.dart';
5 | import 'package:fake_commerce/src/feature/category/presentation/provider/category_list_provider.dart';
6 | import 'package:fake_commerce/src/feature/category/presentation/widgets/category_loading_shimmer.dart';
7 | import 'package:fake_commerce/src/feature/product/products/presentation/riverpod/providers.dart';
8 | import 'package:fake_commerce/src/feature/product/products/presentation/widget/products_loading_shimmer.dart';
9 | import 'package:fake_commerce/src/feature/product/root/data/models/product_model.dart';
10 | import 'package:flutter/material.dart';
11 | import 'package:flutter_riverpod/flutter_riverpod.dart';
12 | import 'package:go_router/go_router.dart';
13 |
14 | part '../widget/category_builder.dart';
15 | part '../widget/product_card.dart';
16 | part '../widget/product_list_builder.dart';
17 |
18 | class ProductListPage extends ConsumerStatefulWidget {
19 | const ProductListPage({Key? key}) : super(key: key);
20 |
21 | @override
22 | ConsumerState createState() => _ProductListPageState();
23 | }
24 |
25 | class _ProductListPageState extends ConsumerState {
26 | @override
27 | void initState() {
28 | super.initState();
29 | Future.microtask(() {
30 | ref.read(productsProvider.notifier).productList();
31 | });
32 | }
33 |
34 | @override
35 | Widget build(BuildContext context) {
36 | final state = ref.watch(productsProvider);
37 | final categoriesState = ref.watch(categoriesProvider);
38 |
39 | return Scaffold(
40 | appBar: AppBar(
41 | title: const Text('Products'),
42 | actions: [
43 | IconButton(
44 | onPressed: () {
45 | context.pushNamed(Routes.login.name);
46 | },
47 | icon: const Icon(
48 | Icons.login,
49 | ),
50 | )
51 | ],
52 | ),
53 | body: Column(
54 | children: [
55 | /// Categories
56 | categoriesState.when(
57 | data: (categories) {
58 | return _CategoryBuilder(categories: categories);
59 | },
60 | loading: () => const CategoryLoadingShimmer(),
61 | error: (error, stackTrace) {
62 | log(
63 | "ProductListPage.categoriesState.when",
64 | error: error.toString(),
65 | stackTrace: stackTrace,
66 | );
67 | return const Center(child: Text('Error'));
68 | },
69 | ),
70 |
71 | /// Product List
72 | state is LoadingState
73 | ? const Expanded(child: ProductsLoadingShimmer())
74 | : state is SuccessState>
75 | ? Expanded(
76 | child: RefreshIndicator(
77 | onRefresh: () async {
78 | ref.invalidate(selectedCategoryProvider);
79 | await ref
80 | .read(productsProvider.notifier)
81 | .productList();
82 | },
83 | child: _ProductListBuilder(products: state.data!),
84 | ),
85 | )
86 | : const Center(child: Text('Error')),
87 | ],
88 | ),
89 | );
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/network/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: network
2 | description: A new Flutter project.
3 |
4 | # The following defines the version and build number for your application.
5 | # A version number is three numbers separated by dots, like 1.2.43
6 | # followed by an optional build number separated by a +.
7 | # Both the version and the builder number may be overridden in flutter
8 | # build by specifying --build-name and --build-number, respectively.
9 | # In Android, build-name is used as versionName while build-number used as versionCode.
10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
12 | # Read more about iOS versioning at
13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14 | #
15 | # This version is used _only_ for the Runner app, which is used if you just do
16 | # a `flutter run` or a `flutter make-host-app-editable`. It has no impact
17 | # on any other native host app that you embed your Flutter project into.
18 | version: 1.0.0+1
19 |
20 | environment:
21 | sdk: '>=2.18.2 <3.0.0'
22 |
23 | dependencies:
24 | flutter:
25 | sdk: flutter
26 | # Network and Connectivity
27 | dio: 5.1.1
28 | http_parser: 4.0.2
29 | # Logging
30 | pretty_dio_logger: 1.3.1
31 | logger: 1.1.0
32 | # Utils
33 | internet_connection_checker: 1.0.0+1
34 | equatable: 2.0.5
35 |
36 |
37 |
38 | # The following adds the Cupertino Icons font to your application.
39 | # Use with the CupertinoIcons class for iOS style icons.
40 | cupertino_icons: ^1.0.2
41 |
42 | dev_dependencies:
43 | flutter_test:
44 | sdk: flutter
45 | flutter_lints: ^2.0.0
46 |
47 | # For information on the generic Dart part of this file, see the
48 | # following page: https://dart.dev/tools/pub/pubspec
49 |
50 | flutter:
51 | # The following line ensures that the Material Icons font is
52 | # included with your application, so that you can use the icons in
53 | # the material Icons class.
54 | uses-material-design: true
55 |
56 | # To add Flutter specific assets to your application, add an assets section,
57 | # like this:
58 | # assets:
59 | # - images/a_dot_burr.jpeg
60 | # - images/a_dot_ham.jpeg
61 |
62 | # An image asset can refer to one or more resolution-specific "variants", see
63 | # https://flutter.dev/assets-and-images/#resolution-aware
64 |
65 | # For details regarding adding assets from package dependencies, see
66 | # https://flutter.dev/assets-and-images/#from-packages
67 |
68 | # To add Flutter specific custom fonts to your application, add a fonts
69 | # section here, in this "flutter" section. Each entry in this list should
70 | # have a "family" key with the font family name, and a "fonts" key with a
71 | # list giving the asset and other descriptors for the font. For
72 | # example:
73 | # fonts:
74 | # - family: Schyler
75 | # fonts:
76 | # - asset: fonts/Schyler-Regular.ttf
77 | # - asset: fonts/Schyler-Italic.ttf
78 | # style: italic
79 | # - family: Trajan Pro
80 | # fonts:
81 | # - asset: fonts/TrajanPro.ttf
82 | # - asset: fonts/TrajanPro_Bold.ttf
83 | # weight: 700
84 | #
85 | # For details regarding fonts from package dependencies,
86 | # see https://flutter.dev/custom-fonts/#from-packages
87 |
88 |
89 | # This section identifies your Flutter project as a module meant for
90 | # embedding in a native host app. These identifiers should _not_ ordinarily
91 | # be changed after generation - they are used to ensure that the tooling can
92 | # maintain consistency when adding or modifying assets and plugins.
93 | # They also do not have any bearing on your native host application's
94 | # identifiers, which may be completely independent or the same as these.
95 | module:
96 | androidX: true
97 | androidPackage: com.brainstation23.network
98 | iosBundleIdentifier: com.brainstation23.network
99 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: fake_commerce
2 | description: A new Flutter project.
3 | # The following line prevents the package from being accidentally published to
4 | # pub.dev using `flutter pub publish`. This is preferred for private packages.
5 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev
6 |
7 | # The following defines the version and build number for your application.
8 | # A version number is three numbers separated by dots, like 1.2.43
9 | # followed by an optional build number separated by a +.
10 | # Both the version and the builder number may be overridden in flutter
11 | # build by specifying --build-name and --build-number, respectively.
12 | # In Android, build-name is used as versionName while build-number used as versionCode.
13 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
14 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
15 | # Read more about iOS versioning at
16 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
17 | # In Windows, build-name is used as the major, minor, and patch parts
18 | # of the product and file versions while build-number is used as the build suffix.
19 | version: 1.0.0+1
20 |
21 | environment:
22 | sdk: '>=2.19.6 <3.0.0'
23 |
24 | # Dependencies specify other packages that your package needs in order to work.
25 | # To automatically upgrade your package dependencies to the latest versions
26 | # consider running `flutter pub upgrade --major-versions`. Alternatively,
27 | # dependencies can be manually updated by changing the version numbers below to
28 | # the latest version available on pub.dev. To see which dependencies have newer
29 | # versions available, run `flutter pub outdated`.
30 | dependencies:
31 | flutter:
32 | sdk: flutter
33 | flutter_riverpod: 2.3.6
34 | dio: 5.1.1
35 | dartz: 0.10.1
36 | shimmer: 2.0.0
37 | go_router: 7.0.0
38 | # The following adds the Cupertino Icons font to your application.
39 | # Use with the CupertinoIcons class for iOS style icons.
40 | cupertino_icons: ^1.0.2
41 | network:
42 | path: network
43 |
44 | dev_dependencies:
45 | flutter_test:
46 | sdk: flutter
47 |
48 | # The "flutter_lints" package below contains a set of recommended lints to
49 | # encourage good coding practices. The lint set provided by the package is
50 | # activated in the `analysis_options.yaml` file located at the root of your
51 | # package. See that file for information about deactivating specific lint
52 | # rules and activating additional ones.
53 | flutter_lints: ^2.0.0
54 |
55 | # For information on the generic Dart part of this file, see the
56 | # following page: https://dart.dev/tools/pub/pubspec
57 |
58 | # The following section is specific to Flutter packages.
59 | flutter:
60 |
61 | # The following line ensures that the Material Icons font is
62 | # included with your application, so that you can use the icons in
63 | # the material Icons class.
64 | uses-material-design: true
65 |
66 | # To add assets to your application, add an assets section, like this:
67 | # assets:
68 | # - images/a_dot_burr.jpeg
69 | # - images/a_dot_ham.jpeg
70 |
71 | # An image asset can refer to one or more resolution-specific "variants", see
72 | # https://flutter.dev/assets-and-images/#resolution-aware
73 |
74 | # For details regarding adding assets from package dependencies, see
75 | # https://flutter.dev/assets-and-images/#from-packages
76 |
77 | # To add custom fonts to your application, add a fonts section here,
78 | # in this "flutter" section. Each entry in this list should have a
79 | # "family" key with the font family name, and a "fonts" key with a
80 | # list giving the asset and other descriptors for the font. For
81 | # example:
82 | # fonts:
83 | # - family: Schyler
84 | # fonts:
85 | # - asset: fonts/Schyler-Regular.ttf
86 | # - asset: fonts/Schyler-Italic.ttf
87 | # style: italic
88 | # - family: Trajan Pro
89 | # fonts:
90 | # - asset: fonts/TrajanPro.ttf
91 | # - asset: fonts/TrajanPro_Bold.ttf
92 | # weight: 700
93 | #
94 | # For details regarding fonts from package dependencies,
95 | # see https://flutter.dev/custom-fonts/#from-packages
96 |
--------------------------------------------------------------------------------
/network/lib/src/utils/failures.dart:
--------------------------------------------------------------------------------
1 | import 'package:equatable/equatable.dart';
2 |
3 | abstract class Failure extends Equatable {
4 | const Failure(
5 | this.name,
6 | this.code,
7 | this.error,
8 | );
9 |
10 | final String? name;
11 | final String? code;
12 | final dynamic error;
13 |
14 | @override
15 | List