Line data Source code
1 : import '../enums/enums.dart'; 2 : import '../errors/errors.dart'; 3 : 4 : /// Provides extension methods on the LocationAccuracy enum. 5 : extension IntergerExtensions on int { 6 : /// Tries to convert the int value to a LocationPermission enum value. 7 : /// 8 : /// Throws an InvalidPermissionException if the int value cannot be 9 : /// converted to a LocationPermission. 10 2 : LocationPermission toLocationPermission() { 11 : switch (this) { 12 2 : case 0: 13 : return LocationPermission.denied; 14 2 : case 1: 15 : return LocationPermission.deniedForever; 16 2 : case 2: 17 : return LocationPermission.whileInUse; 18 2 : case 3: 19 : return LocationPermission.always; 20 : default: 21 1 : throw InvalidPermissionException(this); 22 : } 23 : } 24 : }