QrImage类/qr_flutter包中的错误

huangapple go评论73阅读模式
英文:

Errors on QrImage class/qr_flutter package

问题

这是错误截图。

在图片中,你会注意到大部分都是关于Dart/Flutter的QrImage类的。我假设可能是Dart或Flutter的版本兼容性问题,或者可能涉及导入'package:qr_flutter/qr_flutter.dart'。

以下是代码:

...

在我的pubspec.yaml文件中,我尝试将qr_flutter的版本从^4.0.0更改为^4.1.0,但没有任何变化,错误仍然存在。我还尝试添加了qr_flutter的依赖项:

qr_flutter:
git:
url: https://github.com/theyakka/qr.flutter.git


但也没有任何变化。

Flutter版本:3.7.12
Dart版本:2.19.6
qr_flutter版本:^4.1.0

我将我的Flutter和Dart版本降级到这些版本,因为公司的移动应用项目需要支持空安全。我使用了这篇文章作为指南:https://dart.dev/null-safety/migration-guide
英文:

This is the screenshot of the errors

In the image, you would notice its mostly about the QrImage class for Dart/Flutter. I assumed there was a compatibility issue with the version of either Dart or Flutter, or maybe it involves the importing of 'package:qr_flutter/qr_flutter.dart'.

Here is the code:

import 'dart:convert';
import 'package:boilerplate/Services/Authentication/AuthService.dart';
import 'package:boilerplate/ViewModel/ProfileViewModels/ProfileViewModel.dart';
import 'package:boilerplate/ui/Event/event_widgets.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:crypto/crypto.dart';

class AgentQR extends StatefulWidget {
  const AgentQR({Key? key}) : super(key: key);

  @override
  State<AgentQR> createState() => _AgentQRState();
}

class _AgentQRState extends State<AgentQR> {
  String hashedQr() {
    //hashes the date and time to create a unique qr code for each transaction
    var bytes1 = utf8.encode(
        "${DateTime.now().month}${DateTime.now().day}${DateTime.now().hour}"); // data being hashed
    var hashedDate = sha256.convert(bytes1);
    var detailsProvider = context.read<ProfileViewModel>();
    return "${AuthService().getUserID()}:${detailsProvider.firstName} ${detailsProvider.lastName}:${detailsProvider.location}:$hashedDate";
  }

  @override
  void initState() {
    super.initState();
    //isQrExist();
  }

    @override
    Widget build(BuildContext context) {
      return QrImage(
      data: hashedQr(),
      errorCorrectionLevel: QrErrorCorrectLevel.H,
      version: QrVersions.auto,
      backgroundColor: Colors.white,
      foregroundColor: Colors.black,
      gapless: true,
      padding: EdgeInsets.all(7),
      );
    }
 }


In my pubspec.yaml file, I tried changing the version of qr_flutter from ^4.0.0 to ^4.1.0 but nothing happened, the errors were still present. I also tried adding a dependency for qr_flutter:

 qr_flutter:
     git:
       url: https://github.com/theyakka/qr.flutter.git

nothing happened as well.

Flutter version: 3.7.12
Dart version: 2.19.6
qr_flutter version: ^4.1.0

I downgraded my flutter and dart to these versions because the mobile app project of the company requires a null-safety. I used this article as a guide: https://dart.dev/null-safety/migration-guide

答案1

得分: 0

4.0.1版本中存在重大更改

https://pub.dev/packages/qr_flutter/changelog

4.0.1
将qr依赖项提升(从^2.0.0到^3.0.0)。
重大更改:将QrImage重命名为QrImageView。

英文:

There was a breaking change in 4.0.1

https://pub.dev/packages/qr_flutter/changelog

4.0.1 
Bump qr dependency (from ^2.0.0 to ^3.0.0).
BREAKING: Rename QrImage to QrImageView

答案2

得分: 0

QrImageView(
data: hashedQr(),
errorCorrectionLevel: QrErrorCorrectLevel.H,
version: QrVersions.auto,
gapless: true,
backgroundColor: Colors.white,
eyeStyle: QrEyeStyle(color: Colors.black),
);

英文:
QrImageView(
 data: hashedQr(),
 errorCorrectionLevel: QrErrorCorrectLevel.H,
 version: QrVersions.auto,
 gapless: true,
 backgroundColor:Colors.white,
 eyeStyle: QrEyeStyle(color: Colors.black),
);

huangapple
  • 本文由 发表于 2023年7月6日 14:12:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76625982.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定