buildUserDrawerHeader method

  1. @protected
Widget buildUserDrawerHeader(
  1. BuildParameters params
)

Implementation

@protected
Widget buildUserDrawerHeader(BuildParameters params) {
  Widget? accountName = builder.tryBuildWidget(
      params.context,
      params.widgets["accountNameWidget"],
      params.state,
      params.parentContext);
  accountName ??= params.props["accountName"] != null
      ? Text(params.props["accountName"])
      : null;
  Widget? accountEmail = builder.tryBuildWidget(
      params.context,
      params.widgets["accountEmailWidget"],
      params.state,
      params.parentContext);
  accountEmail ??= params.props["accountEmail"] != null
      ? Text(params.props["accountEmail"])
      : null;
  Widget? currentAccountPicture = builder.tryBuildWidget(
      params.context,
      params.widgets["accountPictureWidget"],
      params.state,
      params.parentContext);

  final accountPicture = params.props["accountPicture"];
  if (currentAccountPicture == null && accountPicture != null) {
    var uri = Uri.tryParse(accountPicture);
    if (uri != null) {
      currentAccountPicture =
          CircleAvatar(backgroundImage: NetworkImage(accountPicture));
    } else {
      currentAccountPicture = CircleAvatar(child: Text(accountPicture));
    }
  }

  return UserAccountsDrawerHeader(
    key: properties.getKey(params.id),
    accountName: accountName,
    accountEmail: accountEmail,
    currentAccountPicture: currentAccountPicture,
    currentAccountPictureSize: Size.square(
        parseDouble(params.props["accountPictureSize"], defaultValue: 72.0)),
    decoration: params.buildProp("decoration"),
    arrowColor:
        parseColor(params.props["arrowColor"], defaultColor: Colors.white),
    onDetailsPressed: events.getFunction(params.context,
        params.actions["onTap"], params.state, params.parentContext),
  );
}