sortButtons method

List sortButtons(
  1. List buttons
)

Implementation

List<dynamic> sortButtons(List<dynamic> buttons) {
  buttons.sort((a, b) {
    bool isPrimaryA = a['primary'].toLowerCase() == "true";
    bool isPrimaryB = b['primary'].toLowerCase() == "true";

    if (isPrimaryA && !isPrimaryB) {
      return 1;
    } else if (!isPrimaryA && isPrimaryB) {
      return -1;
    } else {
      return 0;
    }
  });

  return buttons;
}