Make Authentication Module

Generate Authentication module with (credentials or phone)

Credentials Components:

  • Login screen
  • Register screen
  • Verify-PinCode screen
  • ForgetPassword screen
  • ResetPassword screen
  • ChangePassword screen

Phone Components:

  • Login screen
  • Verify-PinCode screen
xflutter_cli make auth

Authentication Entity

  • CLI will look for Entity like (User) for handle it with authentication_controller, if this entity not found in the project it will ask for some info to generate model

Module Architecture

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

Layers Architecture

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

Result:

  • Layers Architecture with Phone Auth type
  • Modules Architecture with Credentials type
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
          • remote
            • authentication
              • authentication_remote_data_source.dart
              • authentication_remote_data_source.g.dart
        • models
          • entities
            • user
          • requests
            • get_verification_code_request
            • login_request
            • verify_code_request
        • repositories
          • authentication
            • authentication_repository.dart
            • authentication_repository_impl.dart
      • mediators
        • controllers
          • authentication_controller.dart
      • router
      • ui
        • screens
          • authentication
            • login
            • verify_pin_code
      • 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
      • common
        • data
          • models
            • entities
              • user
        • router
        • mediators
          • controllers
            • authentication_controller.dart
      • modules
        • authentication
          • data
            • data_sources
              • remote
                • authentication
                  • authentication_remote_data_source.dart
                  • authentication_remote_data_source.g.dart
            • models
              • requests
                • change_password_request
                • get_verification_code_request
                • login_request
                • register_request
                • reset_password_request
                • verify_code_request
            • repositories
              • authentication
                • authentication_repository.dart
                • authentication_repository_impl.dart
          • presentation
            • screens
              • change_password
              • forget_password
              • login
              • register
              • reset_password
              • verify_pin_code
      • 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)-
auth-typesoption
auth module type
  • credentials: authentication with email and password
  • phone: authentication with phone number and verification code
credentials, phone
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