createSpace method

Future<String> createSpace({
  1. String? name,
  2. String? topic,
  3. Visibility visibility = Visibility.public,
  4. String? spaceAliasName,
  5. List<String>? invite,
  6. List<Invite3pid>? invite3pid,
  7. String? roomVersion,
  8. bool waitForSync = false,
})

Creates a new space and returns the Room ID. The parameters are mostly the same like in createRoom(). Be aware that spaces appear in the rooms list. You should check if a room is a space by using the room.isSpace getter and then just use the room as a space with room.toSpace().

https://github.com/sdn-org/sdn-doc/blob/matthew/msc1772/proposals/1772-groups-as-rooms.md

Implementation

Future<String> createSpace(
    {String? name,
    String? topic,
    Visibility visibility = Visibility.public,
    String? spaceAliasName,
    List<String>? invite,
    List<Invite3pid>? invite3pid,
    String? roomVersion,
    bool waitForSync = false}) async {
  final id = await createRoom(
    name: name,
    topic: topic,
    visibility: visibility,
    roomAliasName: spaceAliasName,
    creationContent: {'type': 'm.space'},
    powerLevelContentOverride: {'events_default': 100},
    invite: invite,
    invite3pid: invite3pid,
    roomVersion: roomVersion,
  );

  if (waitForSync) {
    await waitForRoomInSync(id, join: true);
  }

  return id;
}