pocketbase_utils 0.0.2
pocketbase_utils: ^0.0.2 copied to clipboard
pocketbase_utils is a dart library that generates Dart models code from a PocketBase collections scheme json file.
PocketBase Utils #
Dart package that creates a binding between your pocketbase server and your Flutter app by generating typesafe boilerplate code of your collections from pb_schema.json file.
Usage #
You can use this package directly through the command line on any device with Dart installed.
Follow these steps to get started:
1. Download the collections schema #
- Open your pocketbase admin panel and go to
Settings/Export collections. - Click on "Download as JSON" button.
- Save the file into the project (the root is default by the config).
Reminder: You may also want to add your file into the.gitignore.
2. Install the package #
Add the package into your pubspec.yaml:
...
dev_dependencies:
...
pocketbase_utils: x.x.x
You also have to install the json_serializable package.
3. Configure package #
Add package configuration to your pubspec.yaml file. Here is a full configuration for the package:
...
pocketbase_utils:
enabled: true # Required. Must be set to true to activate the package. Default: false
pb_schema_path: pb_schema.json # Optional. Sets the path of your collection schema file. Default: pb_schema.json
output_dir: lib/generated/pocketbase # Optional. Sets the directory of generated model files. If the directory doesn't exist — it'll be created. Default: lib/generated/pocketbase
line_length: 80 # Optional. Sets the length of line for dart formatter of generated code. Default: 80
4. Run the generator #
In the root of your flutter project run:
flutter pub run pocketbase_utils:generate
This will produce files inside lib/generated/pocketbase directory.
You can also change the output folder to a custom directory by adding the output_dir line in your pubspec.yaml file.
Contributing #
Contributions are welcome! Please create an issue or make a fork and propose a PR to contribute to this project.
License #
This project is licensed under the Apache License 2.0.