fluttercommunity / wakelock_plus

Flutter plugin that allows you to keep the device screen awake on Android, iOS, macOS, Windows, Linux, and web.
BSD 3-Clause "New" or "Revised" License
71 stars 54 forks source link

show use of try block in examples. #79

Open bsutton opened 9 hours ago

bsutton commented 9 hours ago

Thanks for the package.

Just some feedback on the doco.

Every example of calling enable or disable should be awaited. Whilst technically you don't need to await them it's considered best practice to await or explicitly unawait any async calls.

The examples should also show a try block around any enable/disable calls to ensure that the disable method is called even if an exception is thrown.

await WakelockPlus.enable();
try {

/// do something and an exception might be thrown

}
finally {
/// ensure the wake lock is relased.
await WakelockPlus.disable();
}