initRoom method Null safety

Future<bool> initRoom(
  1. [RoomType? roomType,
  2. String? subDir]
)

Used to init/open room's

Usage:

  • Call initRoom before runApp or navigate to another screen that REQUIRE call any room.
  • If you don't define roomType, ALL the room's will be loaded.

Parameters:

  • roomType this will define which room will be opened/loaded/used.
  • subDir this will be the path to create/load room's.

Important:

  • This method will ONLY work 100% if you add a async/await, if don't, the widget will load almost in the same time and will throw a error.
  • REMEMBER TO CLOSE THE ROOM'S INSIDE THE DISPOSE..

Example:

void main() async {
  //Init Room.
  await OnAudioRoom().initRoom(RoomType.FAVORITES);
  runApp(MaterialApp(home: MyApp()));
}

Return:

  • initRoom will ALWAYS return a bool:
    • true if the room/path is loaded
    • false if something wrong happend or path is null

See also:

Implementation

Future<bool> initRoom([RoomType? roomType, String? subDir]) async {
  await Hive.initFlutter(subDir);
  return roomType == null
      ? await _controller.openAll
      : await roomType.openRoom;
}