openBubble method

void openBubble({
  1. String topText = '',
  2. String middleText = '',
  3. String bottomText = '',
  4. String topTextColor = '#000000',
  5. String middleTextColor = '#000000',
  6. String bottomTextColor = '#000000',
  7. String backgroundColor = '#ffffff',
  8. String? topIconAsset,
  9. String? bottomIconAsset,
  10. Timer? callback,
})

Start Bubble service and show the bubble, hiding the app, with optional topText, middleText, bottomText, topTextColor, middleTextColor, bottomTextColor, backgroundColor, topIconAsset, bottomIconAsset and callback

Implementation

void openBubble({
  String topText = '',
  String middleText = '',
  String bottomText = '',
  String topTextColor = '#000000',
  String middleTextColor = '#000000',
  String bottomTextColor = '#000000',
  String backgroundColor = '#ffffff',
  String? topIconAsset,
  String? bottomIconAsset,
  Timer? callback,
}) async {
  var bytesTop = topIconAsset == null
      ? null
      : (await rootBundle.load(topIconAsset)).buffer.asUint8List();
  var bytesBottom = bottomIconAsset == null
      ? null
      : (await rootBundle.load(bottomIconAsset)).buffer.asUint8List();
  _platform.invokeMethod('openBubble', [
    topText,
    middleText,
    bottomText,
    topTextColor,
    middleTextColor,
    bottomTextColor,
    backgroundColor,
    bytesTop,
    bytesBottom,
  ]);
  setCallback(callback);

  ///Creates [_timer] to check periodically if
  ///bubble [isOpen] if Service is bounded, [true] if bounded,
  ///[false] otherwise
  _timer = Timer.periodic(Duration(seconds: 1), (timer) async {
    _isOpen = await _platform.invokeMethod('isBubbleOpen') ?? false;
    if (!_isOpen) {
      timer.cancel();
    }
  });
}