number<T extends num> method

T number<T extends num>({
  1. required String key,
  2. String? description,
  3. required T initial,
  4. required T min,
  5. required T max,
})

Creates int or double knob.

Implementation

T number<T extends num>({
  /// Knob node key.
  required String key,
  /// Knob node description.
  String? description,
  /// Knob node initial value.
  required T initial,
  /// Knob node minimum value.
  required T min,
  /// Knob node maximum value.
  required T max,
}) {
  final knobProvider = KnobsProvider.of(this);
  final storyProvider = StoryProvider.of(this);

  final knobNode = knobProvider.knobStore.addStoryKnob(
    storyProvider.story.key,
    knobKey: key,
    knobNode: KnobNodeNumber<T>(
      key: key,
      description: description,
      min: min,
      max: max,
      value: initial,
    ),
  );

  return knobNode.value;
}