Julian Steenbakker

imp: add link for hot-restart issue, add macos check for textureId

@@ -262,12 +262,13 @@ class _MobileScannerState extends State<MobileScanner> @@ -262,12 +262,13 @@ class _MobileScannerState extends State<MobileScanner>
262 // If debug mode is enabled, stop the controller first before starting it. 262 // If debug mode is enabled, stop the controller first before starting it.
263 // If a hot-restart is initiated, the controller won't be stopped, and because 263 // If a hot-restart is initiated, the controller won't be stopped, and because
264 // there is no way of knowing if a hot-restart has happened, we must assume 264 // there is no way of knowing if a hot-restart has happened, we must assume
265 - // every start is a hot-restart. 265 + // every start is a hot-restart. Related issue:
  266 + // https://github.com/flutter/flutter/issues/10437
266 if (kDebugMode) { 267 if (kDebugMode) {
267 - final platformInterface = MobileScannerPlatform.instance;  
268 - if (MobileScannerPlatform.instance case final MethodChannelMobileScanner implementation) { 268 + if (MobileScannerPlatform.instance
  269 + case final MethodChannelMobileScanner implementation) {
269 try { 270 try {
270 - await platformInterface.stop(force: true); 271 + await implementation.stop(force: true);
271 } catch (e) { 272 } catch (e) {
272 // Don't do anything if the controller is already stopped. 273 // Don't do anything if the controller is already stopped.
273 debugPrint('$e'); 274 debugPrint('$e');
@@ -496,6 +496,10 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -496,6 +496,10 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
496 } 496 }
497 497
498 private func releaseTexture() { 498 private func releaseTexture() {
  499 + if (textureId == nil) {
  500 + return
  501 + }
  502 +
499 registry.unregisterTexture(textureId) 503 registry.unregisterTexture(textureId)
500 textureId = nil 504 textureId = nil
501 } 505 }