package Ġco . sol x . wifi _ info _ android Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroidx . annotation . NonNull Ċ import Ġandroid . content . Context Ċ import Ġandroid . net . wifi . Wifi Manager Ċ Ċ import Ġio . flutter . embedding . engine . plugins . Flutter Plugin Ċ 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 ĊĊ Ċ /** ĠW ifi Info Android Plugin Ġ*/ Ċ class ĠW ifi Info Android Plugin : ĠFlutter Plugin , ĠMethod Call Handler Ġ{ ĊĠ Ġ/// ĠThe ĠMethod Channel Ġthat Ġwill Ġthe Ġcommunication Ġbetween ĠFlutter Ġand Ġnative ĠAndroid ĊĠ Ġ/// ĊĠ Ġ/// ĠThis Ġlocal Ġreference Ġserves Ġto Ġregister Ġthe Ġplugin Ġwith Ġthe ĠFlutter ĠEngine Ġand Ġunregister Ġit ĊĠ Ġ/// Ġwhen Ġthe ĠFlutter ĠEngine Ġis Ġdet ached Ġfrom Ġthe ĠActivity ĊĠ Ġprivate Ġlateinit Ġvar Ġchannel : ĠMethod Channel ĊĠ Ġprivate Ġvar Ġapplication Context : ĠContext ? Ġ= Ġnull ĊĊĠ Ġoverride Ġfun Ġon Attached To Engine (@ NonNull Ġflutter Plugin Binding : ĠFlutter Plugin . Flutter Plugin Binding ) Ġ{ ĊĠĠĠ Ġapplication Context Ġ= Ġflutter Plugin Binding . application Context ĊĠĠĠ Ġchannel Ġ= ĠMethod Channel ( flutter Plugin Binding . binary Messenger , Ġ" wifi _ info _ android ") ĊĠĠĠ Ġchannel . set MethodCall Handler ( this ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Detached From Engine (@ NonNull Ġbinding : ĠFlutter Plugin . Flutter Plugin Binding ) Ġ{ ĊĠĠĠ Ġapplication Context Ġ= Ġnull ĊĠĠĠ Ġchannel . set MethodCall Handler ( null ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon MethodCall (@ NonNull Ġcall : ĠMethod Call , Ġ@ NonNull Ġresult : ĠResult ) Ġ{ ĊĠĠĠ Ġif Ġ( call . method Ġ== Ġ" get Wifi Info ") Ġ{ ĊĠĠĠĠĠ Ġget Wifi Info ( result ) ĊĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠ Ġresult . not Implemented () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġget Wifi Info ( result : ĠMethod Channel . Result ) Ġ{ ĊĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠ Ġval Ġwifi Manager Ġ= Ġapplication Context ?. getSystem Service ( Context . WIFI _ SERVICE ) Ġas ĠW ifi Manager ĊĠĠĠĠĠ Ġif Ġ( wifi Manager Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠ Ġresult . success ( null ); ĊĠĠĠĠĠĠĠ Ġreturn ; ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġval Ġwifi Info Ġ= Ġwifi Manager . connection Info ĊĠĠĠĠĠ Ġresult . success ( mutable Map Of ( ĊĠĠĠĠĠĠĠ Ġ" b ssid " Ġto Ġwifi Info . getB SSID (), ĊĠĠĠĠĠĠĠ Ġ" ssid " Ġto Ġwifi Info . get SSID (), ĊĠĠĠĠĠĠĠ Ġ" rssi " Ġto Ġwifi Info . getR ssi (), ĊĠĠĠĠĠĠĠ Ġ" isConnected " Ġto Ġ( wifi Info . get Network Id () Ġ!= Ġ- 1 ) ĊĠĠĠĠĠ Ġ)) ĊĠĠĠ Ġ} Ġcatch ( e : ĠException ) Ġ{ ĊĠĠĠĠĠ Ġresult . error (" now ifi ", Ġ" Got Ġexception Ġwhen Ġtrying Ġto Ġread ĠWi - Fi Ġstate ", Ġnull ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ