build method

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

Implementation

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

  final pushReplacementRouting = centerChild != null;

  return Row(
    mainAxisSize: MainAxisSize.min,
    children: <Widget>[
      Flexible(
        child: rlwBuilder(
          (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 (center != null) Flexible(flex: 3, child: center),
      // we have an expanded as well
      if (expanded != null) Flexible(flex: 2, child: expanded),
      // Fallback if neither is in our route
      if (center == null && expanded == null)
        const Flexible(flex: 2, child: ChatSelectPage()),
    ],
  );
}