build method

  1. @override
dynamic build(
  1. dynamic context
)

Implementation

@override
Widget build(BuildContext context) {
  if (!context.isLargeScreen) {
    // we only have space to show the deepest child:
    if (expandedChild != null) {
      return expandedChild!;
    } else if (centerChild != null) {
      return centerChild!;
    } else {
      // no children, show the room list
      return RoomsListWidget(
        onSelected: (String roomId) => context.pushNamed(
          Routes.chatroom.name,
          pathParameters: {'roomId': roomId},
        ),
      );
    }
  }

  final pushReplacementRouting = centerChild != null;

  return Row(
    mainAxisSize: MainAxisSize.min,
    children: <Widget>[
      Flexible(
        child: RoomsListWidget(
          onSelected: (String roomId) => pushReplacementRouting
              ? context.pushReplacementNamed(
                  // we switch without "push"
                  Routes.chatroom.name,
                  pathParameters: {'roomId': roomId},
                )
              : context.pushNamed(
                  // we switch without "push"
                  Routes.chatroom.name,
                  pathParameters: {'roomId': roomId},
                ),
        ),
      ),
      // we have a room selected
      if (centerChild != null)
        Flexible(
          flex: 3,
          child: centerChild!,
        ),
      // we have an expanded as well
      if (expandedChild != null)
        Flexible(
          flex: 2,
          child: expandedChild!,
        ),
      // Fallback if neither is in our route
      if (centerChild == null && expandedChild == null)
        const Flexible(
          flex: 2,
          child: ChatSelectPage(),
        ),
    ],
  );
}