I want to know that how to kill a and restart a flutter app from that app itself ??

ForumI want to know that how to kill a and restart a flutter app from that app itself ??
Shavneet Grewal asked 6 months ago

I am using this code :
getCameraPermissionStatus() async {
var get = ”;
List permissions = await Permission.getPermissionsStatus(
[PermissionName.Camera,]);
permissions.forEach((permission) {
get += ‘${permission.permissionName}: ${permission.permissionStatus}’;
if (get != “PermissionName.Camera: PermissionStatus.allow”) {
requestCameraPermission();
} else {
Lamp.turnOn();
}
});
}
requestCameraPermission() async {
final res = await Permission.requestPermissions([PermissionName.Camera,]);
res.forEach((permission) {
String a = ‘${permission.permissionStatus}’;
setState(() {
if (a == ‘PermissionStatus.allow’) {
Lamp.turnOn();
}
else {
Permission.openSettings;
}
});
});
}
So with this code I am successfully turning On the camera permission but ”Lamp.turnOn()” is not turning on the flash in first attempt . Has to restart the app to turn it on . Permission gets turned on in first attempt (can be checked in app info ) but starts working after killing app and restarting app .
Packages I am using :
permission: ^0.1.1
lamp: ^0.0.6 .
Please help if anyone knows anything about this or any other ideas will be appreciated . Thanks .