Replaced math based approach with bitwise operations
This commit is contained in:
parent
916ea41159
commit
b73362c101
1 changed files with 30 additions and 26 deletions
|
@ -69,14 +69,18 @@ class _EditRoomPermissionSetPageState extends State<EditRoomPermissionSetPage> {
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final item = items[index];
|
final item = items[index];
|
||||||
|
|
||||||
final int col = pow(2, index + 1) as int;
|
final int col = pow(2, index) as int;
|
||||||
|
|
||||||
return SwitchListTile(
|
return SwitchListTile(
|
||||||
title: Text(RoomPermission.name(item, context)),
|
title: Text(RoomPermission.name(item, context)),
|
||||||
subtitle: Text(RoomPermission.describe(item, context)),
|
subtitle: Text(RoomPermission.describe(item, context)),
|
||||||
onChanged: (state) {
|
onChanged: (state) {
|
||||||
setState(() {
|
setState(() {
|
||||||
permissions += (state ? 1 : -1) * col;
|
if (state) {
|
||||||
|
permissions |= col;
|
||||||
|
} else {
|
||||||
|
permissions &= ~col;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
value: permissions & col != 0);
|
value: permissions & col != 0);
|
||||||
|
|
Loading…
Reference in a new issue