Skip to content

Commit

Permalink
feat: Add addKnob method to KnobsBuilder (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
buehler committed Mar 13, 2024
1 parent a77b2e4 commit 7fd848b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/storybook_flutter/lib/src/knobs/knobs_builder.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:storybook_flutter/src/knobs/select_knob.dart';
import 'package:storybook_flutter/src/knobs/knobs.dart';

/// {@template knobs_builder}
/// Provides helper methods for creating knobs: control elements
Expand Down Expand Up @@ -68,6 +68,10 @@ abstract class KnobsBuilder {
required T initial,
List<Option<T>> options = const [],
});

/// Allows to add a custom knob.
/// Using the convenience functions (boolean, text, ...) is recommended.
T addKnob<T>(Knob<T> knob);
}

/// {@template nullable_knobs_builder}
Expand Down
1 change: 1 addition & 0 deletions packages/storybook_flutter/lib/src/plugins/knobs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class KnobsNotifier extends ChangeNotifier implements KnobsBuilder {

/// Allows to add a knob to the current story.
/// Using the convenience functions (boolean, text, ...) is recommended.
@override
T addKnob<T>(Knob<T> value) {
// ignore: avoid-non-null-assertion, having null here is a bug
final story = _storyNotifier.currentStory!;
Expand Down

0 comments on commit 7fd848b

Please sign in to comment.