show method

void show()

Implementation

void show() {
  _show = true;
  showDialog(
    context: context,
    barrierDismissible: barrierDismissible,
    builder: (BuildContext context) => PopScope(
      canPop: false,
      // TODO(edufolly): Check onPopInvokedWithResult
      // ignore: deprecated_member_use
      onPopInvoked: (_) {
        if (_alreadyPopped) {
          return;
        }

        if (_closeable) {
          _streamController.close();
          _alreadyPopped = true;
          Navigator.of(context).pop();
        }
      },
      child: Dialog(
        child: StreamBuilder<Map<String, dynamic>>(
          stream: _streamController.stream,
          builder: (
            BuildContext context,
            AsyncSnapshot<Map<String, dynamic>> snapshot,
          ) {
            String msg = message;
            String? sub = subtitle;
            double? dbl;

            if (snapshot.hasData) {
              msg = snapshot.data!['message'];
              sub = snapshot.data!['subtitle'];
              dbl = snapshot.data!['value'];
            }

            return Padding(
              padding: const EdgeInsets.all(30),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  CircularProgressIndicator(
                    value: dbl,
                  ),
                  Padding(
                    padding: const EdgeInsets.only(top: 12),
                    child: Column(
                      children: <Widget>[
                        Text(
                          msg,
                          style: const TextStyle(
                            fontSize: 20,
                          ),
                        ),
                        if (sub != null && sub.isNotEmpty)
                          Padding(
                            padding: const EdgeInsets.only(top: 4),
                            child: Text(
                              sub,
                              style: const TextStyle(
                                fontSize: 12,
                              ),
                            ),
                          ),
                      ],
                    ),
                  ),
                ],
              ),
            );
          },
        ),
      ),
    ),
  );
}