mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 07:29:40 +00:00
Merge pull request #76 from SyncrowIOT/bugifx/empty-subspace-routine-creation
fixed issue on empty subspace
This commit is contained in:
@ -29,25 +29,38 @@ class _SceneRoomsTabBarDevicesViewState
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
selectedSpace = HomeCubit.getInstance().selectedSpace!;
|
||||
rooms = List.from(HomeCubit.getInstance().selectedSpace?.subspaces ?? []);
|
||||
if (rooms != null) {
|
||||
if (rooms![0].id != '-1') {
|
||||
rooms?.insert(
|
||||
0,
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
selectedSpace = HomeCubit.getInstance().selectedSpace!;
|
||||
|
||||
rooms = List.from(selectedSpace.subspaces ?? []);
|
||||
|
||||
if (rooms != null && rooms!.isNotEmpty) {
|
||||
if (rooms![0].id != '-1') {
|
||||
rooms?.insert(
|
||||
0,
|
||||
SubSpaceModel(
|
||||
name: 'All Devices',
|
||||
devices: context.read<DevicesCubit>().allDevices,
|
||||
id: '-1',
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
rooms = [
|
||||
SubSpaceModel(
|
||||
name: 'All Devices',
|
||||
devices: context.read<DevicesCubit>().allDevices,
|
||||
id: '-1',
|
||||
),
|
||||
);
|
||||
)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
_tabController =
|
||||
TabController(length: rooms!.length, vsync: this, initialIndex: 0);
|
||||
_tabController.addListener(_handleTabSwitched);
|
||||
super.initState();
|
||||
_tabController = TabController(length: rooms!.length, vsync: this);
|
||||
_tabController.addListener(_handleTabSwitched);
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void _handleTabSwitched() {
|
||||
|
Reference in New Issue
Block a user