Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartDialog.show关闭后 马上调用SmartDialog.showLoading();不能正常显示 #209

Closed
yaolv7 opened this issue Aug 27, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@yaolv7
Copy link

yaolv7 commented Aug 27, 2024

Version Information

  • Flutter version: v3.22.3
  • flutter_smart_dialog version: 4.9.8

Describe the bug/requirement

SmartDialog.show关闭后 马上调用SmartDialog.showLoading();不能正常显示Loading

Problem demo


    void main() {
     runApp(const MyApp());
   }

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

    @override
    Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
      navigatorObservers: [FlutterSmartDialog.observer],
      builder: FlutterSmartDialog.init(),
    );
    }
  }

  class MyHomePage extends StatefulWidget {
    const MyHomePage({super.key, required this.title});

    final String title;

    @override
    State<MyHomePage> createState() => _MyHomePageState();
  }

  class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: TextButton(onPressed: _onPressed, child: const Text('弹出Dialog')),
      ),
    );
  }

    Future<void> _onPressed() async {
    var result = await SmartDialog.show<bool>(
        tag: 'tag',
        backDismiss: false,
        clickMaskDismiss: false,
        builder: (_) {
          return ElevatedButton(
            onPressed: () async {
              await SmartDialog.dismiss(tag: 'tag', result: true);
              // return true;
            },
            child: const Text('关闭Dialog,显示Loading'),
          );
        },
        onDismiss: () {
          // showLoading()放在这里能正常显示
          // SmartDialog.showLoading();
        });

    if (result == true) {
      // showLoading() 放在这里需要加一点延时才能显示Loading
      // await Future.delayed(const Duration(seconds: 1));
      SmartDialog.showLoading();

      // 延时关闭Loading
      await Future.delayed(const Duration(seconds: 2));
      SmartDialog.dismiss();
    }
  }
 }

目前是放在onDismiss里使用,小白一个,不知道啥情况。感谢大佬百忙之中抽时间来看下 Orz

@xdd666t xdd666t self-assigned this Aug 27, 2024
@xdd666t xdd666t added the bug Something isn't working label Sep 1, 2024
xdd666t added a commit that referenced this issue Sep 1, 2024
@xdd666t
Copy link
Member

xdd666t commented Sep 1, 2024

  • 解决了, 试下新版本
dependencies:
  flutter_smart_dialog: ^4.9.8+1

@xdd666t xdd666t closed this as completed Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants