Widgetbook GeneratorOverviewA VSCode extension which helps you automate the process of adding new widget entries for Widgetbook - a widget library for Flutter. FeaturesThe extension allows you to generate a base for widgetbook use-cases for a chosen widget (or for the whole directory of widgets). It will go through the widget, and for every constructor it will create a widgetbook use case. All those use cases will be put in one file which should be a representation of a chosen widget in the widgetbook. For each constructor property the extension will try to find the most suitable knob. There is a set of predefined type-knob pairs. You can also configure your own knobs (see Custom Knobs) and override existing ones. If none of defined types matches the property, it's assumed the property is a custom enum (so NOTE: The code generated by the extension should always be revised and corrected where needed. The extension is just supposed to provide a solid base for further adjustments, do the job of writing repeatable, schematic code. InstallationThe extension can be installed from the VSCode Marketplace. ConfigurationA couple of settings need to be specified for the extension to work. They can be set in VSCode Settings after typing "widgetbook" in the searchbar.
Those settings are purely project specific. If you work on multiple projects at the same time and all of them use widgetbook, you can override above settings for each of them. Just create
UsageBefore using the extension to generate files, make sure you've configured your extension before by following steps described in Configuration. Also, make sure the code meets the requirements. Generating Widgetbook Entries for a Single WidgetPut the cursor on the line with class name declaration, press a shortcut for Generating Widgetbook Entries for the Entire Widget DirectoryIn VSCode explorer, right-click on the directory that contains widgets for which you want to generate entries, then select Note: This feature is currently experimental and may require adjustments. We're working on making it stable. Custom KnobsThe extension allows for adding custom knobs for specified types (e.g. your custom widgets/enums that you want to handle differently). These custom knobs can also override knobs predefined by the extension. To define custom knobs, create a JSON file containing your knobs, and set the Custom Knob Path property from Configuration section. Your JSON structure should look like this:
NotesThis project is still in very early stage of development. If you find that something is not working properly or you think some features are missing, feel free to create an issue or even a pull request. Disclaimer: This is not an official Widgetbook extension. It's made and maintained by the community. RequirementsSince the project is still in very early stage of development, some rules need to be followed for the extension to work correctly.
|