initRoom method
Used to init/open room's
Usage:
- Call initRoom before runApp or
navigateto another screen that REQUIRE call any room. - If you don't define
roomType, ALL the room's will be loaded.
Parameters:
roomTypethis will define which room will be opened/loaded/used.subDirthis 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:
trueif the room/path is loadedfalseif something wrong happend or path isnull
See also:
Implementation
Future<bool> initRoom([RoomType? roomType, String? subDir]) async {
await Hive.initFlutter(subDir);
return roomType == null
? await _controller.openAll
: await roomType.openRoom;
}