- Replace QR package with another reade made one to exclude error being from painting QR - Revert QR version change so its re-producible if it happens again
- Replace QR package with another reade made one to exclude error being from painting QR - Revert QR version change so its re-producible if it happens again
OmarHatem committed
Jan 30, 2023 at 20:03 UTC
425914ade3a04648229c1c045b4b9709046ecbc8
3 files changed
+19
-64
lib/src/screens/receive/widgets/qr_image.dart
+18
-16
@@ -1,30 +1,32 @@
1
import 'package:flutter/material.dart';
2
-import 'package:qr/qr.dart';
3
-import 'package:cake_wallet/src/screens/receive/widgets/qr_painter.dart';
2
+import 'package:qr_flutter/qr_flutter.dart' as qr;
3
4
class QrImage extends StatelessWidget {
5
QrImage({
7
- required String data,
6
+ required this.data,
7
this.size = 100.0,
8
this.backgroundColor,
10
- Color foregroundColor = Colors.black,
11
- int version = 13, // Previous value: 9 BTC & LTC wallets addresses are longer than ver. 9
12
- int errorCorrectionLevel = QrErrorCorrectLevel.L,
13
- }) : _painter = QrPainter(data, foregroundColor, version, errorCorrectionLevel);
9
+ this.foregroundColor = Colors.black,
10
+ this.version = 9, // Previous value: 7 something happened after flutter upgrade monero wallets addresses are longer than ver. 7 ???
11
+ this.errorCorrectionLevel = qr.QrErrorCorrectLevel.L,
12
+ });
13
15
- final QrPainter _painter;
14
final Color? backgroundColor;
15
final double size;
16
+ final String data;
17
+ final int version;
18
+ final int errorCorrectionLevel;
19
+ final Color foregroundColor;
20
21
@override
22
Widget build(BuildContext context) {
21
- return Container(
22
- width: size,
23
- height: size,
24
- color: backgroundColor,
25
- child: CustomPaint(
26
- painter: _painter,
27
- ),
23
+ return qr.QrImage(
24
+ data: data,
25
+ errorCorrectionLevel: errorCorrectionLevel,
26
+ version: version,
27
+ size: size,
28
+ foregroundColor: foregroundColor,
29
+ padding: EdgeInsets.zero,
30
);
31
}
30
-}
\ No newline at end of file
32
+}
lib/src/screens/receive/widgets/qr_painter.dart
deleted
-47
@@ -1,47 +0,0 @@
1
-import 'package:flutter/material.dart';
2
-import 'package:qr/qr.dart';
3
-
4
-class QrPainter extends CustomPainter {
5
- QrPainter(
6
- String data,
7
- this.color,
8
- this.version,
9
- this.errorCorrectionLevel,
10
- ) : this._qr = QrCode(version, errorCorrectionLevel)..addData(data) {
11
- _p.color = this.color;
12
- _qrImage = QrImage(_qr);
13
- }
14
-
15
- final int version;
16
- final int errorCorrectionLevel;
17
- final Color color;
18
-
19
- final QrCode _qr;
20
- final _p = Paint()..style = PaintingStyle.fill;
21
- late QrImage _qrImage;
22
-
23
- @override
24
- void paint(Canvas canvas, Size size) {
25
- final squareSize = size.shortestSide / _qr.moduleCount;
26
- for (int x = 0; x < _qr.moduleCount; x++) {
27
- for (int y = 0; y < _qr.moduleCount; y++) {
28
- if (_qrImage.isDark(y, x)) {
29
- final squareRect = Rect.fromLTWH(
30
- x * squareSize, y * squareSize, squareSize, squareSize);
31
- canvas.drawRect(squareRect, _p);
32
- }
33
- }
34
- }
35
- }
36
-
37
- @override
38
- bool shouldRepaint(CustomPainter oldDelegate) {
39
- if (oldDelegate is QrPainter) {
40
- return this.color != oldDelegate.color ||
41
- this.errorCorrectionLevel != oldDelegate.errorCorrectionLevel ||
42
- this.version != oldDelegate.version;
43
- }
44
-
45
- return false;
46
- }
47
-}
pubspec_base.yaml
+1
-1
@@ -6,7 +6,7 @@ dependencies:
6
flutter_cupertino_localizations: ^1.0.1
7
intl: ^0.17.0
8
url_launcher: ^6.1.4
9
- qr: ^3.0.1
9
+ qr_flutter: ^4.0.0
10
uuid: 3.0.6
11
shared_preferences: ^2.0.15
12
flutter_secure_storage: