Generating Scaffolding ๐
The simplest scaffolding options generate a create, read, update and delete (CRUD) application and the home view.
Let's do that from the command line using the prompts:
mason make scaffolding
? What is the package name of your flutter project? (scaffolding_sample) scaffolding_sample
? What is your feature name (eg. Todo, DiaryProject, contact) ? (feature1) feature1
? Enter property list in the following format "String firstname=Your first name, String lastname=Your suranme, bool registered=false" ? String firstname=Your first name, String lastname=Your suranme, bool registered=false
? Do you want unit tests generated? n
? Do you want to generate the home page / main function ? (y/N) y
This will then run scaffolding and list the files:
You have the following properties: [{name: firstname, type: String, defaultValue: 'Your first name', emptyValue: '', testValue: 'testString'}, {name: lastname, type: String, defaultValue: 'Your suranme', emptyValue: '', testValue: 'testString'}, {name: registered, type: bool, defaultValue: false, emptyValue: false, testValue: true}]
โ Made brick scaffolding (0.1s)
โ Generated 15 file(s):
.../static_scaffolding_sample/lib/features/feature1/feature1.dart (new)
.../static_scaffolding_sample/lib/features/feature1/data/feature1_repository_impl.dart (new)
.../static_scaffolding_sample/lib/features/feature1/data/feature1_model.dart (new)
.../static_scaffolding_sample/lib/features/feature1/domain/feature1_repository.dart (new)
.../static_scaffolding_sample/lib/features/feature1/domain/feature1.dart (new)
.../static_scaffolding_sample/lib/features/feature1/presentation/views/feature1_edit_view.dart (new)
.../static_scaffolding_sample/lib/features/feature1/presentation/views/feature1_read_view.dart (new)
.../static_scaffolding_sample/lib/features/feature1/presentation/widgets/feature1_widget.dart (new)
.../static_scaffolding_sample/lib/features/feature1/presentation/bloc/feature1_edit_event.dart (new)
.../static_scaffolding_sample/lib/features/feature1/presentation/bloc/feature1_edit_bloc.dart (new)
.../static_scaffolding_sample/lib/features/feature1/presentation/bloc/feature1_edit_state.dart (new)
.../static_scaffolding_sample/lib/features/feature1/presentation/bloc/feature1_read_event.dart (new)
.../static_scaffolding_sample/lib/features/feature1/presentation/bloc/feature1_read_bloc.dart (new)
.../static_scaffolding_sample/lib/features/feature1/presentation/bloc/feature1_read_state.dart (new)
.../static_scaffolding_sample/lib/shared/presentation/list_table.dart (new)
โ Running brick scaffolding_home (0.7s)
โ Generated 2 file(s):
.../static_scaffolding_sample/lib/main.dart (new)
.../static_scaffolding_sample/lib/scaffold_app.dart (new)
You now have a scaffolded application ๐ - if you select the main.dart file you will be able to run the file and see screen similar to the ones below after you create a new contact.
The file structure is as follows:
lib/
โโ main.dart
โโ scaffold_app.dart
โโ features/
โ โโ feature1/
โ โโ data/
โ โ โโ feature1_model.dart
โ โ โโ feature1_repository_impl.dart
โ โโ domain/
โ โ โโ feature1_repository.dart
โ โ โโ feature1.dart
โ โโ presentation/
โ โโ bloc/
โ โ โโ feature1_edit_bloc.dart
โ โ โโ feature1_edit_event.dart
โ โ โโ feature1_edit_state.dart
โ โ โโ feature1_read_bloc.dart
โ โ โโ feature1_read_event.dart
โ โ โโ feature1_read_state.dart
โ โโ views/
โ โโ feature1_edit_view.dart
โ โโ feature1_read_view.dart
โโ shared/
โโ presentation/
โโ list_table.dart
Ok let's learn about more options.