ookami-kb / storybook_flutter

A storybook for Flutter widgets.
https://pub.dev/packages/storybook_flutter
MIT License
284 stars 63 forks source link

Global knob to have values shared between all stories #97

Open caiovisk opened 1 year ago

caiovisk commented 1 year ago

Need to have a Knob that keep its value when changing between stories.

For example, a Font Size options knob that is present on all stories:

context.knobs.options(
      label: 'Font Size',
      initial: '12',
      options: [
        const Option<String>(
          label: '10',
          value: '10',
        ),
        const Option<String>(
          label: '11',
          value: '11',
        ),
        const Option<String>(
          label: '12',
          value: '12',
        ),
        const Option<String>(
          label: '13',
          value: '13',
        ),
        const Option<String>(
          label: '14',
          value: '14',
        )
      ],
    );
Screen Shot 2022-12-19 at 12 23 10 pm

The "issue" is when I select a different value, let's say 11, and navigates to a different story, the "Font Size" knob value gets reset to its initial value. So there is a need to select the knob again.

Is there a way I could declare a global knob of "settings" or have its initial value to be kept between all stories??