Generate Screens

Generate Screen with ability to generate ViewModel and Responsive Layouts with it.
xflutter_cli generate screen

Generate new screen inside workspace

  • Make sure to run the command in the workspace root directory instead of (application or package) directory.
  • Use the src option to specify the (app or package) in which you want to generate the screen.

Generate Screen with Flags:

Result:

  • xflutter_cli_test_application
    • android
    • assets
    • ios
    • lib
      • router
      • ui
        • screens
          • home
            • mobile
            • viewmodels
            • widgets
            • home_screen.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
Example
srcoptionspecify one of the modules to execute command in (monorepo workspace or standalone modular-app)
pathoptiongenerate screen path<ui/screens/{name}> for layer-based
<modules/{module}/presentation/{name}> for feature-based
mobileflaggive you the ability to wrap mobile layout in your screen (only mobile screen will be generated)
tabletflaggive you the ability to wrap tablet and mobile layouts in your screen (generate mobile and tablet screens)
desktopflaggive you the ability to wrap desktop, tablet and mobile layouts in your screen (generate mobile, tablet and desktop screens)
state-managementflaggenerate state-holder (viewModel) with screen to manage variables between screen and children widgets
routerflaggive you ability to manage navigation between screens
themeflagwrap your screen scaffold inside theme builder
back-buttonflagadd back button to generated screen
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 importedfilename.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 importedmodels.dart:my_package1, models.dart:my_package2