Make Crud Module

Generate Data Layer and Ui Layer after Generating Model from json This command works on generating @freezed Model, Data Sources, Repository and (create, update, list, view-details) Screens
xflutter_cli make crud

Check monorepo drawbacks

Module Architecture

  • You will be asked for entity module path like (modules/products)

Layers Architecture

  • You will be asked for ui screens path like (ui/screens/products)

Result:

CLI provides two options to create the Flutter application Layer-Based Architecture and Feature-Based Architecture

Layer-Based Architecture:

  • xflutter_cli_test_application
    • android
    • assets
    • ios
    • lib
      • data
        • data_sources
          • local
            • products
              • products_local_data_source.dart
              • products_local_data_source_impl.dart
          • remote
            • products
              • products_remote_data_source.dart
              • products_remote_data_source.g.dart
        • models
          • entities
            • product
              • product.dart
              • product.freezed.dart
              • product.g.dart
          • local
            • product
              • local_product.dart
        • repositories
          • products
            • products_repository.dart
            • products_repository_impl.dart
      • mediators
        • paging
          • products_paging_controller.dart
      • router
      • ui
        • screens
          • products
            • create_product
              • mobile
              • viewmodels
              • widgets
              • create_product_screen.dart
            • products_list
              • mobile
              • viewmodels
              • widgets
              • products_list_screen.dart
            • update_product
              • mobile
              • viewmodels
              • widgets
              • update_product_screen.dart
            • view_product_details
              • mobile
              • viewmodels
              • widgets
              • view_product_details_screen.dart
            • widgets
              • product_form.dart
      • main.dart
    • analysis_options.yaml
    • build.yaml
    • flutter_launcher_icons.yaml
    • flutter_native_splash.yaml
    • pubspec.yaml
    • xflutter_cli.yaml

Feature-Based Architecture:

  • xflutter_cli_modules_application
    • android
    • assets
    • ios
    • lib
      • modules
        • products
          • data
            • data_sources
              • local
                • products
                  • products_local_data_source.dart
                  • products_local_data_source_impl.dart
              • remote
                • products
                  • products_remote_data_source.dart
                  • products_remote_data_source.g.dart
            • models
              • entities
                • product
                  • product.dart
                  • product.freezed.dart
                  • product.g.dart
              • local
                • product
                  • local_product.dart
            • repositories
              • products
                • products_repository.dart
                • products_repository_impl.dart
          • mediators
            • paging
              • products_paging_controller.dart
          • presentation
            • screens
              • create_product
                • mobile
                • viewmodels
                • widgets
                • create_product_screen.dart
              • products_list
                • mobile
                • viewmodels
                • widgets
                • products_list_screen.dart
              • update_product
                • mobile
                • viewmodels
                • widgets
                • update_product_screen.dart
              • view_product_details
                • mobile
                • viewmodels
                • widgets
                • view_product_details_screen.dart
            • widgets
              • product_form.dart
      • main.dart
    • analysis_options.yaml
    • build.yaml
    • flutter_launcher_icons.yaml
    • flutter_native_splash.yaml
    • pubspec.yaml
    • xflutter_cli.yaml

Usage:

Name
Type
Description
Allowed Values
Example
srcoptionspecify one of the modules to execute command in (monorepo workspace or standalone modular-app)-
crud-typesoption
crud screens and actions types
  • create: generate create entity screen
  • update: generate update entity screen
  • view: generate view-details entity screen
  • list: generate animated_infinite_scroll_pagination screen for entity
  • delete: add delete action to entity card in listView
create, update, view, list, delete
entity-pathoptionjson absolute file path in the disk, or http api end-point-
entity-nameoptionname of entity for generating the data layer-
json-keyoptiongenerate model from specific key, this option is helpful when your model is nested object in json-
end-pointoptionadd custom end-point to APIs, by default the APIs endpoint is the same of entity-name-shop/products
primary-keyoptionspecify local-database entity with name of primary property, default is `id`-
local-databaseflaggenerate local database with remote data-
authorizationoptionadd authorization to your http request headers, Api maybe require authorization for return success response, in this case you need this option-Bearer your_jwt_token
add-entity-prefixflagadd prefix to all entity nested entities, ex: [Product -> Rating] will be [Product -> ProductRating]-
base-diroptiongenerate all/some models in base common directory, used only with (modules-architecture)-dimensions,reviews
sourceoptionimport file from specific module, this is helpful when you have multiple files with same name and one of them should be imported in the generated file, so you need to tell CLI which one should be imported-filename.dart:my_app1
sourcesoptionimport file from multiple modules, this is helpful when you have multiple files with same name and many of them of them should be imported in the generated file, so you need to tell CLI which files should be imported-models.dart:my_package1, models.dart:my_package2