reduced size of qr code

still seen to work with nostrylus.vercel.app
This commit is contained in:
Vishal 2022-11-27 20:12:34 +05:30
parent 494380b5e9
commit 7594939571
2 changed files with 32 additions and 9 deletions

View File

@ -283,22 +283,44 @@ String getQrCodeAsString(String str) {
..addData('$str');
final qrImage = QrImage(qrCode);
assert( qrImage.moduleCount == 33);
//print("qrimage modulecount = ${qrImage.moduleCount}");
String leftPadding = " ";
for (var x = 0; x < qrImage.moduleCount; x++) {
var x = 0;
for (x = 0; x < qrImage.moduleCount -1 ; x += 2) {
output += leftPadding;
for (var y = 0; y < qrImage.moduleCount; y++) {
if (qrImage.isDark(y, x)) {
// render a dark square on the canvas
output += "██";
for (var y = 0; y < qrImage.moduleCount ; y++) {
bool topDark = qrImage.isDark(y, x);
bool bottomDark = qrImage.isDark(y, x + 1);
if (topDark && bottomDark) {
output += "";
}
else {
output += " ";
else if (topDark ) {
output += "";
} else if ( bottomDark) {
output += "";
} else if( !topDark && !bottomDark) {
output += " ";
}
}
output += "\n";
}
if( qrImage.moduleCount %2 == 1) {
output += leftPadding;
for (var y = 0; y < qrImage.moduleCount ; y++) {
bool dark = qrImage.isDark(y, x);
if (dark ) {
output += "";
} else {
output += " ";
}
}
output += "\n";
}
return output;
}
@ -339,7 +361,7 @@ void printProfile(Store node, String profilePubkey) {
try {
print(getQrCodeAsString(profilePubkey));
} catch(e) {
print("Could not generate qr code.\n");
print("Could not generate qr code. \n");
}
if( profilePubkey != userPublicKey) {

View File

@ -6,7 +6,7 @@ homepage: https://github.com/vishalxl/nostr_console
# Release 0.1.9-beta
# used kind 104
# fix for tag related test fail
# default without argument invocation now possible with no pubkey
# default without argument invocation now possible with no pubkey
environment:
sdk: '>=2.17.3 <3.0.0'
@ -25,3 +25,4 @@ dependencies:
web_socket_channel: ^2.2.0
logging: ^1.0.2
kepler: ^1.0.3
qr: ^3.0.1