build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Describes the part of the user interface represented by this widget.

The framework calls this method when this widget is inserted into the tree in a given BuildContext and when the dependencies of this widget change (e.g., an InheritedWidget referenced by this widget changes). This method can potentially be called in every frame and should not have any side effects beyond building a widget.

The framework replaces the subtree below this widget with the widget returned by this method, either by updating the existing subtree or by removing the subtree and inflating a new subtree, depending on whether the widget returned by this method can update the root of the existing subtree, as determined by calling Widget.canUpdate.

Typically implementations return a newly created constellation of widgets that are configured with information from this widget's constructor and from the given BuildContext.

The given BuildContext contains information about the location in the tree at which this widget is being built. For example, the context provides the set of inherited widgets for this location in the tree. A given widget might be built with multiple different BuildContext arguments over time if the widget is moved around the tree or if the widget is inserted into the tree in multiple places at once.

The implementation of this method must only depend on:

If a widget's build method is to depend on anything else, use a StatefulWidget instead.

See also:

  • StatelessWidget, which contains the discussion on performance considerations.

Implementation

@override
Widget build(BuildContext context) {

  ColorScheme colorScheme = Theme.of(context).colorScheme;
  CustomColors colors = CustomColors();
  CustomIcons icons = CustomIcons();

  String displayName = currentProfile['displayName'] ?? '';
  String uid = 'UID: ${currentProfile['uid'] ?? '' }';
  String email = currentProfile['email'] ?? '';

  String textSupport = '\n\nTel: ${support['phoneNumber'] ?? ''} \nEmail: ${support['email'] ?? ''}';

  return Scaffold(
    backgroundColor: colorScheme.surface,
    appBar: CustomAppBarSignout(
      onSignout: onSignout,
      titleWidget: CustomElevatedButton(
        text: currentAccount['accountName'] ?? 'Account',
        textStyle: Theme.of(context).textTheme.titleMedium,
        onPressed: onChangeAccount
      ),
    ),

    body: SizedBox(
      width: MediaQuery.of(context).size.width,
      child:

      // USER MESSAGES /////////////////////////////////////////////////////
      profileState == ProfileState.userInactive
      ? CustomMessage(
        backgroundColor: colorScheme.background,
        icon: Icon(icons.userInactive, size: 64, color: colorScheme.onSurface.withOpacity(.5)),
        title: displayName.toUpperCase(),
        subtitle: uid,
        message: 'Actualmente, no tiene acceso a esta empresa debido a que se encuentra INACTIVO.\n'
        'Puede contactar al administrador para que lo HABILITE.',
      )
      // ACCOUNT MESSAGES /////////////////////////////////////////////////////
      : profileState == ProfileState.accountEmpty
      ? CustomMessage(
        backgroundColor: colorScheme.background,
        icon: Icon(icons.accountEmpty, size: 64, color: colorScheme.onBackground),
        title: displayName.toUpperCase(),
        subtitle: email,
        message: 'No tiene acceso a ninguna empresa. Para continuar, debe realizar alguna de las siguientes opciones:\n\n'
        '1. Si usted es empleado, por favor contácte al administrador para que lo vincule por medio de su correo.\n\n'
        '2. Si usted es propietario y desea registrar su empresa, por favor comuníquese con nosotros. $textSupport'
      ) : profileState == ProfileState.accountError
      ? CustomMessage(
        backgroundColor: colorScheme.background,
        icon: Icon(icons.accountError, size: 64, color: colorScheme.onBackground),
        title: displayName.toUpperCase(),
        subtitle: email,
        message: 'Ha ocurrido un problema al intentar obtener la información de esta empresa, por favor reinicie la app o vuelva a iniciar sesión.\n\n'
        'Si el problema persiste por favor comuníquese con nosotros. $textSupport'
      )
      // SUSCRIPTION MESSAGES /////////////////////////////////////////////////////
      : profileState == ProfileState.suscriptionInactive
      ? CustomMessage(
        backgroundColor: colorScheme.background,
        icon: Icon(icons.suscriptionInactive, size: 64, color: colorScheme.onBackground),
        title: 'SUSCRIPTION INACTVE',
        subtitle: 'ACCOUNT ID: ${currentAccount['id'] ?? ''}',
        message: 'La suscripción de esta empresa se encuentra inactiva, por favor actualice su pago.\n'
        'Si ya lo ha hecho comuníquese con nosotros. $textSupport'
      ) : profileState == ProfileState.suscriptionError
      ? CustomMessage(
        backgroundColor: colorScheme.background,
        icon: Icon(icons.suscriptionError, size: 64, color: colorScheme.onBackground),
        title: 'SUSCRIPTION ERROR',
        subtitle: 'ACCOUNT ID: ${currentAccount['id'] ?? ''}',
        message: 'Ha ocurrido un proble al intentar acceder a la suscripción de esta empresa.\n'
        'Si el problema persiste por favor comuníquese con nosotros. $textSupport'
      ) : profileState == ProfileState.suscriptionExpired
      ? CustomMessage(
        backgroundColor: colorScheme.background,
        icon: Icon(icons.suscriptionExpired, size: 64, color: colorScheme.onBackground),
        title: 'SUSCRIPTION EXPIRED',
        subtitle: 'ACCOUNT ID: ${currentAccount['id'] ?? ''}',
        message: 'El tiempo de suscripción de su empresa ha expirado, por favor actualice su pago.\n'
        'Si ya lo ha hecho comuníquese con nosotros. $textSupport'
      )
      // PAGE MESSAGES /////////////////////////////////////////////////////
      : profileState == ProfileState.pageNoFound
      ? CustomMessage(
        backgroundColor: colorScheme.background,
        icon: Icon(icons.pageNoFound, size: 64, color: colors.warning),
        title: displayName.toUpperCase(),
        subtitle: email,
        message: 'Ha ocurrido un problema al obtener la información de esta página, por favor reinicie la app o vuelva a iniciar sesión.\n\n'
        'Si el problema persiste por favor comuníquese con nosotros. $textSupport'
      ) : profileState == ProfileState.pageDenied
      ? CustomMessage(
        backgroundColor: colorScheme.background,
        icon: Icon(icons.pageDenied, size: 64, color: colors.warning),
        title: displayName.toUpperCase(),
        subtitle: email,
        message: 'No hemos podido obtener la información de esta página, '
        'debido a que no tiene permisos suficientes.'
      )
      // DEFAULT MESSAGE /////////////////////////////////////////////////////
      : CustomMessage(
        backgroundColor: colorScheme.background,
        icon: Icon(icons.pageDefault, size: 64, color: colors.warning),
        title: displayName.toUpperCase(),
        subtitle: email,
        message: profileState.toString()
      )

    ),
  );

}