Skip to content

Flutter app for fetching Products via FakeAPI using flutter_bloc

Notifications You must be signed in to change notification settings

stepanzalis/FakeAPI-Product-Viewer

Repository files navigation

FAKE API Product Viewer

This repository contains test mobile application for Fake Product API.

Recording

 

Getting Started

⚙️ Setup

  • This project is build with Flutter 3.24.0 and uses fvm (Flutter Version Manager)
  • Using fvm is highly recommended, because there is .fvm config dir commited in source to sync Flutter versions for all developers

The app has currently 1 environment:

  • DEV
    • using https://fakestoreapi.com/ of REST API
    • package name cz.stepanzalis.aktin_product_viewer
    • app name Aktin (dev)
    • env app suffix dev

Append this commands when running run or build command with chosen flavor:

  • --dart-define-from-file=.env/development.json

    • defines:
      • REST API url
      • defines package name suffix
  • When using VSCode, there is a launch.json file with predefined configurations for running and building the app with the DEV flavor

📚 Libraries

🏠 Architecture

  • State management is done with BLoC (flutter_bloc)

  • The app is built with a modified clean architecture approach

  • It's divided into features (modules) and each feature has its own folder

    • application - contains business logic
    • domain - contains entities
    • config - contains configuration, DI and navigation
    • infrastructure - contains implementation of repositories, DTOs, services
    • presentation - contains UI (pages & widgets)
  • Each feature should be independent and should not depend on other features except for the core module, which contains shared code

  • Each feature has its own {name}_feature.dart file, which contains all dependencies for the current feature like blocs, repositories, services, etc.

How to create a new feature?

  1. Create a new folder in the lib/features directory
  2. Create the following folders inside the new feature folder: application, domain, config, infrastructure, presentation
  3. Create a {name}_feature.dart file in the feature folder
  4. Create a {name}_injection.dart file in the feature/{name}/config/di directory which extends the InjectableFeature class
  5. Feature registration is done in the config/di/injection.dart file

🐛 Testing

  • The app has unit tests for business logic, repositories and services
  • The app has widget tests for UI using Patrol

About

Flutter app for fetching Products via FakeAPI using flutter_bloc

Resources

Stars

Watchers

Forks