小编Emm*_*el 的帖子

使用 nfc_manager 获取卡数据?

我正在使用 nfc_manager 包来扫描我的交通卡。我在 Playstore 上发现了类似的应用程序,它们能够从应用程序中获取交易历史、卡序列号和其他详细信息。但是,使用 nfc_manager 包,我只能获得 isodep 和 nfcB 数据。下面是 isodep 和 nfcb 数据的打印输出。

{identifier: [123, 123,123,123], hiLayerResponse: [], historicalBytes: null, isExtendedLengthApduSupported: true, maxTransceiveLength: 12312, timeout: 123}
{identifier: [123,123,123,123], applicationData: [0, 0, 0, 0], maxTransceiveLength: 123, protocolInfo: [123,123,123]}
Run Code Online (Sandbox Code Playgroud)

(这些值已更改为 123,因为我不确定数据是否敏感)我如何从我这里拥有的数据中获取诸如运输历史之类的数据?或者这是包的限制?

这是使用的代码:

 NfcManager.instance.startSession(onDiscovered: (NfcTag tag) async {
       print(tag.data['isodep']);
       print(tag.data['nfcb']);

       IsoDep isoDep = IsoDep.from(tag);
       print(isoDep.historicalBytes);
     });
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助!

nfc dart flutter

5
推荐指数
0
解决办法
85
查看次数

FileSystemException:无法打开文件,路径='assets/busStops.txt'(操作系统错误:没有这样的文件或目录,errno = 2)

我似乎无法加载存储在资产中的 txt 文件。每当我尝试访问它时,都会收到以下错误:

FileSystemException: Cannot open file, path = 'assets/busStops.txt' (OS Error: No such file or directory, errno = 2)
Run Code Online (Sandbox Code Playgroud)

我也将该文件添加到我的 pubspec 文件中:

  assets:
    - assets/BusSD.png
    - assets/SubtractBD.png
    - assets/VectorDD.png
    - assets/busRoutes.txt
    - assets/busStops.txt
Run Code Online (Sandbox Code Playgroud)

这是我访问文件的代码


class FileUtilsBusStopInfo {
  static Future<String> get getFilePath async {
    final directory = await getApplicationDocumentsDirectory();
    return directory.path;
  }

  static Future<File> get getFile async {
    //final path = await getFilePath;

    return File('assets/busStops.txt');
  }

  static Future<File> saveToFile(String data) async {
    final file = await getFile;
    return file.writeAsString(data);
  } …
Run Code Online (Sandbox Code Playgroud)

android dart flutter

3
推荐指数
1
解决办法
4848
查看次数

我如何使用 get.snackbar?

每当我尝试调用 get.snackbar 时,都没有显示小吃店?根据 pub.dev 页面,我只需要使用

Get.snackbar(
                  'User 123',
                  'Successfully created',
                );
Run Code Online (Sandbox Code Playgroud)

但是每当我在我的代码中使用它时,都没有显示小吃店?我用错了吗?感谢您的帮助!

flutter flutter-dependencies

1
推荐指数
1
解决办法
1133
查看次数

我如何处理不回来​​的未来?

我正在使用位置插件来获取设备的当前位置。但是,在某些设备上, await getLocation() 永远不会返回(调试控制台中也没有错误)。我该如何处理这样的问题?

这是我的 getCurrentLocation() 代码

import 'package:geolocator/geolocator.dart';
import 'location.dart';

/// Determine the current position of the device.
///
/// When the location services are not enabled or permissions
/// are denied the `Future` will return an error.
Future<Position> getCurrentLocation() async {
  bool serviceEnabled;
  LocationPermission permission;
  Position position;
  await reqLocation(); // requests turn on location
  serviceEnabled = await Geolocator.isLocationServiceEnabled();
  if (!serviceEnabled) {
    return Future.error('Location services are disabled.');
  }

  permission = await Geolocator.checkPermission();
  if (permission == LocationPermission.deniedForever) {
    return Future.error( …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-dependencies

0
推荐指数
1
解决办法
173
查看次数

标签 统计

flutter ×4

dart ×2

flutter-dependencies ×2

android ×1

nfc ×1