Modal<T extends InputBase>.builder constructor

Modal<T extends InputBase>.builder(
  1. String panelText,
  2. String actionText, {
  3. PanelBorder borderType = PanelBorder.single,
  4. int padding = 1,
  5. Color? panelTextColor,
  6. Color? actionTextColor,
  7. Color? backgroundColor,
  8. Color? borderColor,
})

General builder factory for Modals. You need to set the handler functions appropriately based on what you want to use the modal for.

Implementation

factory Modal.builder(String panelText, String actionText,
    {PanelBorder borderType = PanelBorder.single,
    int padding = 1,
    Color? panelTextColor,
    Color? actionTextColor,
    Color? backgroundColor,
    Color? borderColor}) {
  // for each of these, the padding size and 1 for the border on each side
  var minWidth = math.max<int>(panelText.length, actionText.length) +
      ((1 + padding) * 2);
  var minHeight = 3 + ((1 + padding) * 2);

  // create the panel at the origin, we'll use a child terminal to make sure
  //it gets centered
  var panel = BorderPanel(Rect.atOrigin(minWidth, minHeight),
      border: borderType,
      borderColor: borderColor,
      background: backgroundColor,
      padding: padding);

  // add a renderer to draw the panel and action texts
  panel.contentRenderer = (terminal) {
    terminal.drawTextCenter(0, panelText, panelTextColor);
    terminal.drawTextCenter(2, actionText, actionTextColor);
  };

  return Modal<T>(panel);
}