v0.4.0
ndef
여러 유형을 지원하는 NDEF 레코드를 디코딩하고 인코딩하는 Dart 라이브러리입니다.
17좋아요 10.7만30일 다운로드160Pub 점수
AndroidiOSWebmacOSWindowsLinux
여러 유형을 지원하는 NDEF 레코드를 디코딩하고 인코딩하는 Dart 라이브러리입니다.
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
ndef is a Dart library to decode & encode NDEF records, supporting multiple types including (grouped by Type Name Format):
urn:nfc:wkt:), with:
T)U)Sig)Sp), including sub-record:
act)s)t)Hr/Hs/Hm/Hi/Hc/ac/cr)application/vnd.bluetooth.ep.oob)application/vnd.bluetooth.le.oob)urn:nfc:ext:), with:
android.com:pkg)This library is still under active development and subject to breaking API changes and malfunction. Pull requests and issues are most welcomed, especially on:
import 'package:ndef/ndef.dart' as ndef;
// encoding
var uriRecord = new ndef.UriRecord.fromString("https://github.com/nfcim/ndef");
var textRecord = new ndef.TextRecord(text: "Hello");
var encodedUriRecord = uriRecord.encode().toHexString(); /// encode a single record, and use our extension method on [Uint8List]
var encodedAllRecords = ndef.encodeNdefMessage([uriRecord, textRecord]).toHexString(); // encode several records as a message
// decoding
var encodedTextRecord = "d1010f5402656e48656c6c6f20576f726c6421";
var decodedRecords = ndef.decodeRawNdefMessage(encodedTextRecord.toBytes());
assert(decodedRecords.length == 1);
if (decodedRecords[0] is ndef.TextRecord) {
assert(decodeRecords[0].text == "Hello");
} else {
// we will not reach here
}
// data-binding (by implementing payload as dynamic getter / setter)
var origPayload = uriRecord.payload!;
print(origPayload.toHexString());
uriRecord.content = "github.com/nfcim/flutter_nfc_kit";
print(uriRecord.payload!.toHexString()); // changed
uriRecord.payload = origPayload;
print(uriRecord.content); // changed back
// decoding by providing parts of a record
var partiallyDecodedUrlRecord = ndef.decodePartialNdefMessage(ndef.TypeNameFormat.nfcWellKnown, utf8.encode("U"), origPayload, id: Uint8List.fromList([0x1, 0x2]));
See example code for a more complete example.
Refer to the documentation for detailed usage.
사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗