fluttercandies / flutter_smart_dialog

An elegant Flutter Dialog solution | 一种更优雅的 Flutter Dialog 解决方案
MIT License
1.13k stars 142 forks source link

连续调用toast出现不消失的情况 #235

Open thintime-X opened 2 hours ago

thintime-X commented 2 hours ago

版本信息

描述bug/需求

连续性的调用toast,会有持续显示不消失的情况 image

问题demo

import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

void main() {
  runApp(MaterialApp(
    navigatorObservers: [FlutterSmartDialog.observer],
    builder: FlutterSmartDialog.init(),
    home: MyApp(),
  ));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          "Test",
        ),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            show("toast1");
            show("toast2");
          },
          child: const Text(
            "Click",
          ),
        ),
      ),
    );
  }

  Future show(String msg) {
    return SmartDialog.showToast(
      msg,
      alignment: Alignment.center,
      displayType: SmartToastType.last,
      displayTime: const Duration(seconds: 3),
    );
  }
}
thintime-X commented 2 hours ago

目前是必现的情况。