presentView<T> static method

void presentView<T>({
  1. String title = "Popup",
  2. bool isFullScreen = true,
  3. bool useRootContext = false,
  4. bool hasInsetBottom = true,
  5. bool enableDrag = true,
  6. Color? contentColor,
  7. EdgeInsets? contentPadding,
  8. dynamic onChanged(
    1. T result
    )?,
  9. GtdCallback<T?>? onCompleted,
  10. required BuildContext context,
  11. required Builder builder,
})

Implementation

static void presentView<T>({
  String title = "Popup",
  bool isFullScreen = true,
  bool useRootContext = false,
  bool hasInsetBottom = true,
  bool enableDrag = true,
  Color? contentColor,
  EdgeInsets? contentPadding,
  Function(T result)? onChanged,
  GtdCallback<T?>? onCompleted,
  required BuildContext context,
  required Builder builder,
}) async {
  final result = await showModalBottomSheet<T>(
      context: context,
      useSafeArea: true,
      enableDrag: enableDrag,
      isScrollControlled: isFullScreen,
      // backgroundColor: contentColor,
      builder: (BuildContext context) {
        return SafeArea(
          bottom: hasInsetBottom,
          child: LayoutBuilder(builder: (context, constraints) {
            return Column(
              children: [
                Expanded(
                  child: SizedBox(
                    child: Padding(
                      padding: const EdgeInsets.symmetric(vertical: 16),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          AppBar(
                            title: Padding(
                              padding: const EdgeInsets.all(0),
                              child: Text(
                                title,
                                style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
                              ),
                            ),
                            automaticallyImplyLeading: false,
                            actions: [
                              IconButton(
                                  onPressed: () {
                                    Navigator.of(context).pop();
                                  },
                                  icon: const Icon(Icons.close))
                            ],
                          ),
                          Expanded(
                            child: ColoredBox(
                              color: contentColor ?? Colors.white,
                              child: Padding(
                                padding: contentPadding ?? const EdgeInsets.all(16),
                                child: useRootContext ? builder.build(context) : builder,
                              ),
                            ),
                            // child:
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
                SizedBox(
                  height: MediaQuery.viewInsetsOf(context).bottom,
                )
              ],
            );
          }),
        );
      }).then((result) {
    onCompleted?.call(result);
  });
  if (result != null && onChanged != null) {
    onChanged(result);
  }
}