diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart index 5cc880ce..2f997b94 100644 --- a/lib/actions/actions.dart +++ b/lib/actions/actions.dart @@ -6,7 +6,7 @@ import 'package:f_r_e_hub/pages/home_page/home_page_widget.dart'; import 'package:flutter/material.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:sqflite/utils/utils.dart'; -import 'dart:developer' as developer; +import 'dart:developer'; import '/actions/actions.dart' as action_blocks; import '/backend/api_requests/api_calls.dart'; @@ -513,7 +513,7 @@ Uint8List assembleQRPacket(int direction, String identifier, String password) { String paddedBadge = identifier.padLeft(30, '0'); - developer.log("Badge: $paddedBadge"); + log("Badge: $paddedBadge"); for (var i = 0; i < paddedBadge.length; i += 2) { packet.add(int.parse(paddedBadge.substring(i, i + 2), radix: 16)); @@ -554,8 +554,8 @@ Uint8List assembleQRPacket(int direction, String identifier, String password) { var bytes = packet.map((byte) => byte.toRadixString(16).padLeft(2, '0')).join((' ')); - developer.log("Pacote: $packet"); - developer.log("Bytes: $bytes"); + log("Pacote: $packet"); + log("Bytes: $bytes"); return Uint8List.fromList(packet); } @@ -569,14 +569,15 @@ Uint8List hexStringToByteArray(String s) { return data; } -String byteToHexa(List pDados) { +String byteToHexa(Uint8List pDados) { return pDados.map((byte) => byte.toRadixString(16).padLeft(2, '0').toUpperCase()).join(); } -String byteToString(Uint8List bytes) { - return utf8.decode(bytes, allowMalformed: true); +Future byteToString(Uint8List bytes) async { + return String.fromCharCodes(bytes); } + Widget buildQrCode( { required String data, @@ -589,8 +590,8 @@ Widget buildQrCode( required String pass, required int direction } - ) { - + ) { + log('QR Code Data: $data'); try { // Verifica se os dados estão de acordo com as regras de negócio if (data.isEmpty) { @@ -601,16 +602,7 @@ Widget buildQrCode( // Geração do QR Code com a biblioteca qr_flutter const Color backgroundColor = Colors.white; const Color foregroundColor = Colors.black; - return QrImageView( - data: byteToString(assembleQRPacket(direction, identifier, pass)), - version: version, //QrVersions.auto - size: dimension, - errorCorrectionLevel: errorCorrectLevel, - backgroundColor: backgroundColor, - foregroundColor: foregroundColor, - gapless: false, // Ajuste conforme necessário - // Adicione mais customizações aqui conforme os arquivos Java - ); + return QrImageView.withQr(qr: QrCode.fromUint8List(data: assembleQRPacket(direction, identifier, pass), errorCorrectLevel: errorCorrectLevel), size: dimension, padding: const EdgeInsets.all(10), backgroundColor: backgroundColor, foregroundColor: foregroundColor); } catch (e) { // Tratamento de erros return Text("Erro ao gerar QR Code: ${e.toString()}");