package Ġcom . jh oog stra at . fast _ barcode _ scanner ĊĊ Ċ import Ġandroidx . annotation . NonNull ; Ċ import Ġio . flutter . embedding . android . Flutter Activity Ċ Ċ import Ġio . flutter . embedding . engine . plugins . Flutter Plugin ; Ċ import Ġio . flutter . embedding . engine . plugins . activity . Activity Aware ; Ċ import Ġio . flutter . embedding . engine . plugins . activity . Activity Plugin Binding Ċ Ċ import Ġio . flutter . plugin . common . MethodCall Ċ import Ġio . flutter . plugin . common . Method Channel Ċ import Ġio . flutter . plugin . common . Method Channel . MethodCall Handler Ċ import Ġio . flutter . plugin . common . Method Channel . Result Ċ Ċ /** ĠFast Barcode Scanner Plugin Ġ*/ Ċ public Ġclass ĠFast Barcode Scanner Plugin : ĠFlutter Plugin , ĠMethod Call Handler , ĠActivity Aware Ġ{ ĊĠ Ġprivate Ġlateinit Ġvar Ġchannel Ġ: ĠMethod Channel ĊĠ Ġprivate Ġlateinit Ġvar Ġreader : ĠBar code Reader ĊĊĠ Ġoverride Ġfun Ġon Attached To Engine (@ NonNull Ġflutter Plugin Binding : ĠFlutter Plugin . Flutter Plugin Binding ) Ġ{ ĊĠĠĠ Ġchannel Ġ= ĠMethod Channel ( flutter Plugin Binding . binary Messenger , Ġ" com . jh oog stra at / fast _ barcode _ scanner ") ĊĊĠĠĠ Ġreader Ġ= ĠBar code Reader ( flutter Plugin Binding . texture Registry . create Surface Texture ()) Ġ{ Ġbar codes Ġ-> ĊĠĠĠĠĠ Ġbar codes . first OrNull ()?. also Ġ{ Ġbarcode Ġ-> Ġchannel . invoke Method (" read ", ĠlistOf ( barcode String Map [ barcode . format ], Ġbarcode . raw Value )) Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Detached From Engine (@ NonNull Ġbinding : ĠFlutter Plugin . Flutter Plugin Binding ) Ġ{ ĊĊĠ Ġ} ĊĊĠ Ġ// Ġhttps :// flutter . dev / docs / development / packages - and - plugins / plugin - api - migration # ui activity - plugin ĊĠ Ġ// Ġhttps :// github . com / flutter / plugins / blob / master / packages / camera / android / src / main / java / io / flutter / plugins / camera / Camera Plugin . java ĊĠ Ġoverride Ġfun Ġon Attached To Activity ( binding : ĠActivity Plugin Binding ) Ġ{ ĊĠĠĠ Ġreader . attach To Activity ( binding . activity Ġas ĠFlutter Activity ) ĊĠĠĠ Ġbinding . add Request Permissions Result Listener ( reader ) ĊĠĠĠ Ġchannel . set MethodCall Handler ( this ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Detached From Activity () Ġ{ ĊĠĠĠ Ġchannel . set MethodCall Handler ( null ) ĊĠĠĠ Ġreader . detach From Activity () ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Detached From Activity For Config Changes () Ġ{ ĊĠĠĠ Ġon Detached From Activity () ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Re attached To Activity For Config Changes ( binding : ĠActivity Plugin Binding ) Ġ{ ĊĠĠĠ Ġon Attached To Activity ( binding ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon MethodCall (@ NonNull Ġcall : ĠMethod Call , Ġ@ NonNull Ġresult : ĠResult ) Ġ{ ĊĠĠĠ Ġwhen Ġ( call . method ) Ġ{ ĊĠĠĠĠĠ Ġ" start " Ġ-> Ġreader . start ( call . arguments Ġas ĠHashMap < String , ĠAny >, Ġresult ) ĊĠĠĠĠĠ Ġ" stop " Ġ-> Ġreader . stop ( result ) ĊĠĠĠĠĠ Ġ" pause " Ġ-> Ġreader . stop ( result ) ĊĠĠĠĠĠ Ġ" resume " Ġ-> Ġreader . resume ( result ) ĊĠĠĠĠĠ Ġ" toggle Torch " Ġ-> Ġreader . toggle Torch ( result ) ĊĠĠĠĠĠ Ġelse Ġ-> Ġresult . not Implemented () ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ