TemplateBasePage constructor

const TemplateBasePage({
  1. Key? key,
  2. required Widget header,
  3. required Widget footer,
  4. Color? headerBackgroundColor,
  5. Color? footerBackgroundColor,
  6. Widget? body,
  7. bool isList = false,
  8. List<String>? imageUrls,
  9. List<String>? descriptions,
  10. List<VoidCallback?>? onSeeMoreCallbacks,
  11. Widget? bodyWhenEmpty,
  12. String? descriptiveTitle,
  13. String? descriptiveSubtitle,
  14. String? descriptiveImageUrl,
  15. String? descriptiveTextFieldHint,
  16. String? descriptiveButtonText,
  17. bool descriptiveButtonDependsOnText = false,
  18. void descriptiveOnButtonPressed(
    1. String text
    )?,
})

Si se pasan los 3 parámetros de lista, el body se construye como lista de cards. Si las listas están vacías, se muestra el body descriptivo. Si no, se usa el widget body proporcionado.

Implementation

const TemplateBasePage({
  super.key,
  required this.header,
  required this.footer,
  this.headerBackgroundColor,
  this.footerBackgroundColor,
  // Body personalizado
  this.body,
  // Body con lista de elementos
  this.isList = false,
  this.imageUrls,
  this.descriptions,
  this.onSeeMoreCallbacks,
  this.bodyWhenEmpty,
  // Body descriptivo
  this.descriptiveTitle,
  this.descriptiveSubtitle,
  this.descriptiveImageUrl,
  this.descriptiveTextFieldHint,
  this.descriptiveButtonText,
  this.descriptiveButtonDependsOnText = false,
  this.descriptiveOnButtonPressed,
}) : assert(
       !isList || (
         imageUrls != null &&
         descriptions != null &&
         onSeeMoreCallbacks != null &&
         imageUrls.length == descriptions.length &&
         descriptions.length == onSeeMoreCallbacks.length
       ),
       'Si isList es true, los 3 parámetros deben estar presentes y tener el mismo tamaño.',
     ),
     assert(
       body != null ||
           (imageUrls != null &&
               descriptions != null &&
               onSeeMoreCallbacks != null) ||
           descriptiveTitle != null ||
           descriptiveSubtitle != null ||
           descriptiveImageUrl != null ||
           descriptiveTextFieldHint != null ||
           descriptiveButtonText != null ||
           descriptiveOnButtonPressed != null,
       'Debes proporcionar al menos un body, parámetros de lista o parámetros descriptivos.',
     );