build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Implementation

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      leading: widget.appBarLeading == null
          ? null
          : widget.appBarLeading!(context),
      leadingWidth: widget.leadingWidth,
      title: Text(widget.builder.superSingle(context)),
      actions: <Widget>[
        /// Actions
        if (widget.actions != null)
          ...widget.actions!(
            context: context,
            model: _model,
          ),

        /// Save Button
        if (widget.edit)
          IconButton(
            tooltip: widget.saveTooltip,
            icon: FaIcon(
              widget.consumer.routeName.isEmpty
                  ? FontAwesomeIcons.check
                  : FontAwesomeIcons.solidFloppyDisk,
            ),
            onPressed: _save,
          ),
      ],
    ),
    bottomNavigationBar: widget.builder.buildBottomNavigationBar(context),
    body: widget.builder.buildEditBody(
      context,
      _model,
      Form(
        key: _formKey,
        canPop: false,
        onPopInvoked: (_) {
          if (_alreadyPopped) {
            return;
          }

          if (!widget.edit) {
            _alreadyPopped = true;
            Navigator.of(context).pop();
          }

          _formKey.currentState!.save();
          int currentHash = _model.hashCode;

          if (_initialHash != currentHash) {
            if (kDebugMode) {
              print('Hash: $_initialHash - $currentHash');
            }

            FollyDialogs.yesNoDialog(
              context: context,
              message: widget.exitWithoutSaveMessage,
            ).then((bool go) {
              if (go) {
                _alreadyPopped = true;
                Navigator.of(context).pop();
              }
            });
          } else {
            _alreadyPopped = true;
            Navigator.of(context).pop();
          }
        },
        child: SafeStreamBuilder<bool>(
          stream: _controller.stream,
          waitingMessage: widget.waitingMessage,
          builder: (
            BuildContext context,
            bool data,
            _,
          ) =>
              SingleChildScrollView(
            padding: const EdgeInsets.all(24),
            child: ResponsiveGrid(
              rowCrossAxisAlignment: widget.rowCrossAxisAlignment,
              children: widget.formContent(
                context,
                _model,
                edit: widget.edit,
                formValidate: _formKey.currentState?.validate,
                refresh: ({required bool refresh}) =>
                    _controller.add(refresh),
              ),
            ),
          ),
        ),
      ),
    ),
  );
}