@@ -212,16 +212,16 @@ public class FlutterNfcKitPlugin: NSObject, FlutterPlugin, NFCTagReaderSessionDe
212212 }
213213 }
214214 else if case let . miFare( tag) = tag {
215- let blockNumber = arguments [ " index " ] as! UInt8
216- let commandPacket = Data ( [ 0x30 , blockNumber] ) //0x30 is the MIFARE Classic Read Command.
217- tag. sendMiFareCommand ( commandPacket: commandPacket) { ( data, error) in
218- if let error = error {
219- result ( FlutterError ( code: " 405 " , message: " Something is wrong " , details: nil ) )
220- } else {
221- result ( data)
222- }
223- }
224- }
215+ let blockNumber = arguments [ " index " ] as! UInt8
216+ let commandPacket = Data ( [ 0x30 , blockNumber] ) //0x30 is the MIFARE Classic Read Command.
217+ tag. sendMiFareCommand ( commandPacket: commandPacket) { ( data, error) in
218+ if let error = error {
219+ result ( FlutterError ( code: " 405 " , message: " Something is wrong " , details: nil ) )
220+ } else {
221+ result ( data)
222+ }
223+ }
224+ }
225225 else {
226226 result ( FlutterError ( code: " 405 " , message: " readBlock not supported on this type of card " , details: nil ) )
227227 }
@@ -251,14 +251,13 @@ public class FlutterNfcKitPlugin: NSObject, FlutterPlugin, NFCTagReaderSessionDe
251251 let writeCommand = Data ( [ 0xA2 , blockNumber] ) + data //0xA2 is the MIFARE Classic Write Command to write single block.
252252 tag. sendMiFareCommand ( commandPacket: writeCommand) { ( response, error) in
253253 if let error = error {
254- result ( FlutterError ( code: " 500 " , message: " Communication error " , details: nil ) )
254+ result ( FlutterError ( code: " 500 " , message: " Communication error " , details: error . localizedDescription ) )
255255 }
256- else
257- {
256+ else {
258257 result ( nil )
259- }
258+ }
260259 }
261- }
260+ }
262261 else {
263262 result ( FlutterError ( code: " 405 " , message: " writeBlock not supported on this type of card " , details: nil ) )
264263 }
0 commit comments