Skip to content

Automates the integration of Widgetbook into your Flutter project by adding Widgetbook to your project and generating Widgetbook use-cases for all widgets in the project’s `lib` directory.

License

Notifications You must be signed in to change notification settings

GianMen91/widgetbook_setup_script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

📖 Widgetbook Setup Script

License Version Last Commit

Overview

This script automates the integration of Widgetbook into your Flutter project. It scans your lib directory for all widgets (StatelessWidget and StatefulWidget) and generates corresponding Widgetbook use-cases, allowing you to preview them interactively.

Features

  • ✅ Automates the setup of a Widgetbook project within a 'widgetbook' directory, streamlining the steps outlined in the Widgetbook Quick Start Guide.
  • ✅ Scans your Flutter project's lib directory for all widgets.
  • ✅ Generates use-cases for each widget and saves them in widgetbook/lib, preserving the original directory structure.
  • ✅ Runs build_runner to generate the required main.directories.g.dart file.

Usage

Option 1

You can use curl to download and execute the script in one command:

curl -s https://raw.githubusercontent.com/GianMen91/widgetbook_setup_script/main/widgetbook_setup.sh | bash
  • curl -s fetches the script silently.
  • The | bash part pipes it directly into a new Bash process.

Option 2

  1. Place the script in the root directory of your Flutter project (same level as lib, pubspec.yaml, etc.).
  2. Open a terminal in the project root.
  3. Run the script:
bash widgetbook_setup.sh

Running Widgetbook

  1. Once the script is finished and the setup is complete, navigate to the widgetbook directory:
cd widgetbook  
  1. Run the following command to generate the necessary files:
dart run build_runner build
  1. Now, start Widgetbook using:
flutter run

⚠️ Important Notice

During setup, you might see messages about version conflicts or dependency issues. This happens when some packages in your project require different versions to work together.

🔍 What does this mean?

  • If you see a message like "Version solving failed", it means some dependencies need to be adjusted.
  • The error message usually suggests a fix (e.g., changing a package version).

✅ How to Fix It

  1. Check the error message for suggested version changes.

  2. If a solution is provided (e.g., updating a package version), run the suggested command.

  3. If no suggestion is given, try running:

    flutter pub upgrade --major-versions
  4. If the issue persists, manually adjust dependency versions in pubspec.yaml and then run:

    flutter pub get

Contributing

Contributions from users are highly valued and appreciated. Two main ways to contribute to this project are through pull requests and issues.

Pull Requests

  1. Fork the repository and create a branch from the main branch.
  2. Make changes or additions to the code.
  3. Commit the changes, and push them to the branch.
  4. Open a pull request to the main branch with a clear and concise description of the changes.

Issues

  1. Navigate to the Issues section of the repository.
  2. Check if there is an existing issue similar to the one you'd like to create.
  3. If there isn't an existing issue, create a new issue by clicking the "New issue" button.
  4. Provide a descriptive title and detailed information about the proposed changes you want to add to the current script.

Feel free to contribute and share

License

This project is licensed under the MIT License - see the LICENSE file for details.

Buy me a coffee

Buy Me A Coffee

About

Automates the integration of Widgetbook into your Flutter project by adding Widgetbook to your project and generating Widgetbook use-cases for all widgets in the project’s `lib` directory.

Topics

Resources

License

Stars

Watchers

Forks

Languages