show<T, R> static method

Future<R?> show<T, R>({
  1. required BuildContext context,
  2. required List<ModDataHeader> headers,
  3. required List<T> data,
  4. required DataTableSource source,
  5. required dynamic onPageChanged(
    1. int page
    ),
  6. required int totalRecords,
  7. required int currentPage,
  8. required int rowsPerPage,
  9. BorderStyle borderStyle = BorderStyle.none,
  10. Color? oddRowColor,
  11. Color? evenRowColor,
  12. Color? headerBackgroundColor,
  13. Color? footerBackgroundColor,
  14. Color? hoverColor,
  15. String paginationText = 'of',
  16. String rowsPerPageText = 'Rows per page',
  17. dynamic onSort(
    1. String field,
    2. SortDirection direction
    )?,
  18. dynamic onRowsPerPageChanged(
    1. int rowsPerPage
    )?,
  19. List<int> availableRowsPerPage = const [5, 10, 15, 20, 50, 100, 200],
  20. double? paginationBorderRadius = 5,
  21. String? currentSortField,
  22. SortDirection currentSortDirection = SortDirection.none,
  23. double rowHeight = 35.0,
  24. bool fixedHeader = false,
  25. bool enableSimplePagination = false,
  26. dynamic onColumnWidthChanged(
    1. String field,
    2. double newWidth
    )?,
  27. bool enableColumnResize = false,
  28. bool showHorizontalScrollbar = true,
  29. ModDataTableActionBarConfig? actionBarConfig,
  30. List<String>? columnsShow,
  31. Widget? emptyViewWidget,
  32. required Widget header,
  33. Color? modalHeaderColor,
  34. Color? modalBodyColor,
  35. Color? modalFooterColor,
  36. ModModalPosition position = ModModalPosition.center,
  37. ModModalSize size = ModModalSize.lg,
  38. ModModalHeight height = ModModalHeight.auto,
  39. bool fullScreen = false,
  40. double borderRadius = 8.0,
  41. bool barrierDismissible = true,
  42. VoidCallback? onClose,
  43. double? maxWidth,
  44. double? minWidth,
  45. double? maxHeight,
  46. double? minHeight,
  47. EdgeInsets? bodyPadding,
  48. ModDataTableModalFooterConfig footerConfig = const ModDataTableModalFooterConfig(),
})

Shows the DataTableModal as a dialog

Implementation

static Future<R?> show<T, R>({
  required BuildContext context,
  // DataTable required properties
  required List<ModDataHeader> headers,
  required List<T> data,
  required DataTableSource source,
  required Function(int page) onPageChanged,
  required int totalRecords,
  required int currentPage,
  required int rowsPerPage,
  // DataTable optional properties
  BorderStyle borderStyle = BorderStyle.none,
  Color? oddRowColor,
  Color? evenRowColor,
  Color? headerBackgroundColor,
  Color? footerBackgroundColor,
  Color? hoverColor,
  String paginationText = 'of',
  String rowsPerPageText = 'Rows per page',
  Function(String field, SortDirection direction)? onSort,
  Function(int rowsPerPage)? onRowsPerPageChanged,
  List<int> availableRowsPerPage = const [5, 10, 15, 20, 50, 100, 200],
  double? paginationBorderRadius = 5,
  String? currentSortField,
  SortDirection currentSortDirection = SortDirection.none,
  double rowHeight = 35.0,
  bool fixedHeader = false,
  bool enableSimplePagination = false,
  Function(String field, double newWidth)? onColumnWidthChanged,
  bool enableColumnResize = false,
  bool showHorizontalScrollbar = true,
  ModDataTableActionBarConfig? actionBarConfig,
  List<String>? columnsShow,
  Widget? emptyViewWidget,
  // Modal required properties
  required Widget header,
  // Modal optional properties
  Color? modalHeaderColor,
  Color? modalBodyColor,
  Color? modalFooterColor,
  ModModalPosition position = ModModalPosition.center,
  ModModalSize size = ModModalSize.lg,
  ModModalHeight height = ModModalHeight.auto,
  bool fullScreen = false,
  double borderRadius = 8.0,
  bool barrierDismissible = true,
  VoidCallback? onClose,
  double? maxWidth,
  double? minWidth,
  double? maxHeight,
  double? minHeight,
  EdgeInsets? bodyPadding,
  ModDataTableModalFooterConfig footerConfig =
      const ModDataTableModalFooterConfig(),
}) {
  final modalAlignment = position == ModModalPosition.top
      ? Alignment.topCenter
      : position == ModModalPosition.bottom
          ? Alignment.bottomCenter
          : Alignment.center;

  return showDialog<R>(
    context: context,
    barrierDismissible: barrierDismissible,
    builder: (context) => Align(
      alignment: modalAlignment,
      child: ModDataTableModal<T>(
        // DataTable properties
        headers: headers,
        data: data,
        source: source,
        onPageChanged: onPageChanged,
        totalRecords: totalRecords,
        currentPage: currentPage,
        rowsPerPage: rowsPerPage,
        borderStyle: borderStyle,
        oddRowColor: oddRowColor,
        evenRowColor: evenRowColor,
        headerBackgroundColor: headerBackgroundColor,
        footerBackgroundColor: footerBackgroundColor,
        hoverColor: hoverColor,
        paginationText: paginationText,
        rowsPerPageText: rowsPerPageText,
        onSort: onSort,
        onRowsPerPageChanged: onRowsPerPageChanged,
        availableRowsPerPage: availableRowsPerPage,
        paginationBorderRadius: paginationBorderRadius,
        currentSortField: currentSortField,
        currentSortDirection: currentSortDirection,
        rowHeight: rowHeight,
        fixedHeader: fixedHeader,
        enableSimplePagination: enableSimplePagination,
        onColumnWidthChanged: onColumnWidthChanged,
        enableColumnResize: enableColumnResize,
        showHorizontalScrollbar: showHorizontalScrollbar,
        actionBarConfig: actionBarConfig,
        columnsShow: columnsShow,
        emptyViewWidget: emptyViewWidget,
        // Modal properties
        header: header,
        modalHeaderColor: modalHeaderColor,
        modalBodyColor: modalBodyColor,
        modalFooterColor: modalFooterColor,
        position: position,
        size: size,
        height: height,
        fullScreen: fullScreen,
        borderRadius: borderRadius,
        barrierDismissible: barrierDismissible,
        onClose: onClose,
        maxWidth: maxWidth,
        minWidth: minWidth,
        maxHeight: maxHeight,
        minHeight: minHeight,
        bodyPadding: bodyPadding,
        footerConfig: footerConfig,
      ),
    ),
  );
}