ookami-kb / storybook_flutter

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

feat: Add addKnob method to KnobsBuilder #136

Closed buehler closed 8 months ago

buehler commented 8 months ago

This was missed in my "opening" of the addKnob method. Since the KnobsBuilder does not have the method definition one cannot add custom knobs via custom extension. This adds the method definition to the builder such that custom knobs can be added in the future.

buehler commented 8 months ago

Hey @ookami-kb I'm really sorry, I totally missed this small issue. I fixed it in my fork, but forgot to merge it back to the upstream of yours.

It is a very small change that allows custom knobs to be added for sure.

Without this change, the following code is not possible:

extension ButtonKnob on KnobsBuilder {
  T button<T>({
    required String label,
    String? description,
    required T Function() onTap,
  }) =>
      addKnob<T>(
        Knob<T>(
          label: label,
          description: description,
          knobValue: ButtonKnobValue<T>(onTap: onTap),
        ),
      );
}

Because KnobsBuilder does not have the definition of "addKnob".