菜鸟在这里。
我做了一个带有 flutter 的更新检查器,但是如果我选择任何按钮,它就会给我黑屏。
我怎样才能解决这个问题?有任何想法吗?

屏幕

flutter - Navigator.of(context).pop()给我黑屏-LMLPHP
flutter - Navigator.of(context).pop()给我黑屏-LMLPHP

代码

  • 完整来源:https://github.com/TanzenT/LiteCalculator
  • 对话框的一部分来源:

  • import 'package:LiteCalculator/updater/bean/UpdaterBean.dart';
    import 'package:flutter/material.dart';
    
    class UpdateHolder extends StatelessWidget {
      final List<Version> version;
    
      UpdateHolder({Key key, this.version}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return calculateResult(
            version[0].latestVersion, version[1].currentVersion, context);
      }
    
      Widget calculateResult(latestVersion, currentVersion, context) {
        print('Latest Version : ${int.parse(latestVersion)}');
        print('Current Version : ${int.parse(currentVersion)}');
        Widget data;
        if ((int.parse(currentVersion) <= int.parse(latestVersion))) {
          data = Center(
            child: createAlert('Update Required', actions: <Widget>[
              FlatButton(
                child: Text('OK'),
                onPressed: () {
                  print('OK Button Pressed.');
                  Navigator.of(context).pop();
                },
              ),
              FlatButton(
                child: Text('Later'),
                onPressed: () {
                  print('Later Button Pressed.');
                  Navigator.of(context).pop();
                },
              ),
            ]),
          );
        } else
          data = Center();
        return data;
      }
    
      Widget createAlert(content, {List<Widget> actions, title}) {
        AlertDialog snackBar;
        snackBar = AlertDialog(
          content: Text(content),
          actions: actions,
        );
        return snackBar;
      }
    }
    

    最佳答案

    称它为您的弹出窗口,

    void showDialogPopup(){
          showDialog(
            context: context,
            builder: (_)=>AlertDialog(
              backgroundColor: Colors.transparent,
              content: Container(
              child: Center(
                 child: FlatButton(
                   onPressed: (){
                     Navigator.of(context).pop(null);
                   },
                   child: Center(
                     child: Text("close")
                   )
                 )
               )
              )
            )
          );
        }
    

    关于flutter - Navigator.of(context).pop()给我黑屏,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59781569/

    10-09 03:22