g123k / flutter_torch_compat

A plugin to enable or disable the torch of a device that works both on Android (including Android 4.x) and iOS.
https://pub.dev/packages/torch_compat
Apache License 2.0
7 stars 22 forks source link

iOS MissingPluginException - hasTorch #3

Closed tj-noor closed 4 years ago

tj-noor commented 4 years ago

I was adding a quick check to see if the iOS device had a torch and ran into an error.

if (await TorchCompat.hasTorch == false) {
    print('no flash');
    return;
}

Error:

flutter: error trying to get flash status - MissingPluginException(No implementation found for method hasTorch on channel g123k/torch_compat)

Looking through the swift code, the issue was evident and is a quick & simple fix - SwiftTorchCompatPlugin.swift#L27

} else if (call.method == "hasTorch") {
    result(hasTorch())