简体   繁体   English

关闭对话框加载进度

[英]Close Dialog loading progress

Error: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3580 pos 12: ':_debugLocked'.错误:'package:flutter/src/widgets/navigator.dart':断言失败:第 3580 行 pos 12:':_debugLocked'。 is not true.不是真的。

dialog bar shows but there is an error when closing the dialog... is there any other way to close?对话框栏显示,但关闭对话框时出现错误...有没有其他方法可以关闭?

class Dialogs {
  static Future<void> showLoadingDialog(
      BuildContext context, GlobalKey key) async {
    return showDialog<void>(
        context: context,
        barrierDismissible: false,
        builder: (BuildContext context) {
          return new WillPopScope(
              onWillPop: () async => false,
              child: SimpleDialog(
                  key: key,
                  backgroundColor: Colors.black54,
                  children: <Widget>[
                    Center(
                      child: Column(children: [
                        CircularProgressIndicator(),
                        SizedBox(height: 10,),
                        Text("Carregando....",style: TextStyle(color: Colors.blueAccent),)
                      ]),
                    )
                  ]));
        });
  }
}


Future<void> _carregaLugares(BuildContext context) async {
    try {
  
    PlacesSearchResponse response = await places.searchNearbyWithRankBy(Location(latitude, longitude), 'distance');
    print(response.status);
    setState(() {
      if (response.status == "OK") {
        lugares = response.results;
        _saving = false;
      }
    });
      Navigator.of(_keyLoader.currentContext,rootNavigator: true).pop();
    } catch (error) {
      print(error);
    }
  }

call dialog调用对话框

 @override
  Widget build(BuildContext context) {
    setState(() {
      Dialogs.showLoadingDialog(context, _keyLoader);
    });
....

// Hide // 隐藏

Navigator.of(_keyLoader.currentContext,rootNavigator: true).pop(); Navigator.of(_keyLoader.currentContext,rootNavigator: true).pop();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM