Skip to content

Commit 3e5d62c

Browse files
Harry-ChenCopilot
andauthored
fix: apply suggestions from code review
Co-authored-by: Copilot <[email protected]>
1 parent 94059a8 commit 3e5d62c

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,5 @@
200200
* ensure NFC Handler is always alive (#219 by @Akshya107)
201201
* prevent an NPE due to wrong API typing (#220)
202202
* add comment on `poll` related to Samsung API bug (#190, #200)
203-
* Bump tools to Gradle 9.2.1, AGP 8.13.1, Kotlin 2.2.21
203+
* Bump tools to Gradle 9.2.1, AGP 8.13.0, Kotlin 2.2.21
204204
* Now `minSdkVersion` is lowered to 24 (#212)

ios/flutter_nfc_kit/Sources/flutter_nfc_kit/FlutterNfcKitPlugin.swift

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)