show static method

void show(
  1. BuildContext context, {
  2. required String text,
  3. Color? color,
  4. double fontSize = 22,
  5. Duration duration = const Duration(milliseconds: 900),
  6. Alignment alignment = Alignment.center,
})

Inserts a self-removing FloatingComboText into context's Overlay at alignment, and removes it again once the animation finishes — no leftover OverlayEntry or AnimationController to manage.

Implementation

static void show(
  BuildContext context, {
  required String text,
  Color? color,
  double fontSize = 22,
  Duration duration = const Duration(milliseconds: 900),
  Alignment alignment = Alignment.center,
}) {
  final overlay = Overlay.of(context, rootOverlay: true);
  late OverlayEntry entry;
  entry = OverlayEntry(
    builder: (context) => Positioned.fill(
      child: IgnorePointer(
        child: Align(
          alignment: alignment,
          child: FloatingComboText(
            text: text,
            color: color,
            fontSize: fontSize,
            duration: duration,
            onDone: () {
              if (entry.mounted) entry.remove();
            },
          ),
        ),
      ),
    ),
  );
  overlay.insert(entry);
}