Flutter Lecture8
Flutter Lecture8
Flutter Lecture 8
--lib
|--feature_1
| |--screens
| |--widgets
| |--models
| |--services
| |--view_models
|--feature_2
| |--screens
| |--widgets
| |--models
| |--services
| |--view_models
| ...
Folder by Feature CLI Utility
To help with the folder by feature pattern, I authored a very
opinionated CLI tool that generates the folder structure and the feature1/
required files within them to provide an excellent structure for ┣ domain/
code organization, testing while still being maintainable and ┃ ┣ models/
┃ ┃ ┗ feature1_model.dart
easy to use.
┃ ┣ repository/
┃ ┃ ┗ feature1_repository.dart
┃ ┣ services/
┃ ┃ ┗ feature1_service.dart
┃ ┗ feature1_domain.dart
It generates a folder structure like ┣ providers/
┃ ┣ feature1_provider.dart
below: ┃ ┗ providers.dart
┣ screens/
┃ ┣ feature1_screen.dart
┃ ┗ screens.dart
┣ widgets/
┃ ┣ feature1_widget.dart
┃ ┗ widgets.dart
┗ index.dart
Command Usage :wrench:
Make sure you are in the root of your project
2.Directory Structure:
•Upon execution, the command creates a directory named my_package containing the
package's files and configurations.
•Inside my_package, essential files include:AX
•lib/: Directory containing Dart code.
•pubspec.yaml: Configuration file defining the package metadata and dependencies.
3.Package Metadata:
•The pubspec.yaml file contains crucial information about the package:
Utilizing the Package:
To use this package in other Dart
projects, define the package as a
dependency in the project's
pubspec.yaml file:
dependencies:
my_package:
path: ../my_package // Replace with the actual path to the package
Import, Export, Part, and Library Keywords:
3.Library Keyword:
1. Used to define the current file as a library with a specific name.
Example:
File: my_library.dart File: utils.dart
library my_library;
part of my_library;
part 'utils.dart'; // Includes another part of the library
// Code related to utility functions or classes
// Code elements