onOptionsUpdate method

  1. @protected
  2. @mustCallSuper
void onOptionsUpdate(
  1. BubbleOptions? oldOptions
)

Called when the behaviour got new options and should update accordingly.

Implementation

@protected
@mustCallSuper
void onOptionsUpdate(BubbleOptions? oldOptions) {
  if (bubbles == null) return;
  if (bubbles!.length > options.bubbleCount)
    bubbles!.removeRange(0, bubbles!.length - options.bubbleCount);
  else if (bubbles!.length < options.bubbleCount) {
    final int numToSpawn = options.bubbleCount - bubbles!.length;
    final newBubbles = generateBubbles(numToSpawn);
    bubbles!.addAll(newBubbles);
  }
}