Browse Source

minor changes

pull/6/head
Khoren Markosyan 2 years ago
parent
commit
363f1d1130
  1. 10
      ios/Classes/src/native_zxing.cpp
  2. 10
      lib/src/utils/extentions.dart

10
ios/Classes/src/native_zxing.cpp

@ -52,13 +52,13 @@ extern "C"
size_t size = (wcslen(resultText) + 1) * sizeof(wchar_t);
code.text = new char[size];
std::wcstombs(code.text, resultText, size);
platform_log("zxingRead: %ls", resultText);
platform_log("zxingRead: %ls\n", resultText);
}
int evalInMillis = static_cast<int>(get_now() - start);
if (logEnabled)
{
platform_log("zxingRead: %d ms", evalInMillis);
platform_log("zxingRead: %d ms\n", evalInMillis);
}
return code;
}
@ -99,14 +99,14 @@ extern "C"
codes[i] = code;
i++;
platform_log("zxingRead: %s", code.text);
platform_log("zxingRead: %s\n", code.text);
}
}
int evalInMillis = static_cast<int>(get_now() - start);
if (logEnabled)
{
platform_log("zxingRead: %d ms", evalInMillis);
platform_log("zxingRead: %d ms\n", evalInMillis);
}
return {i, codes};
}
@ -138,7 +138,7 @@ extern "C"
int evalInMillis = static_cast<int>(get_now() - start);
if (logEnabled)
{
platform_log("zxingEncode: %d ms", evalInMillis);
platform_log("zxingEncode: %d ms\n", evalInMillis);
}
return result;
}

10
lib/src/utils/extentions.dart

@ -2,6 +2,7 @@ import 'dart:ffi';
import 'dart:typed_data';
import 'package:ffi/ffi.dart';
import 'package:flutter/foundation.dart';
import '../../flutter_zxing.dart';
@ -27,7 +28,14 @@ extension EncodeExt on EncodeResult {
String? get textString =>
text == nullptr ? null : text.cast<Utf8>().toDartString();
String get formatString => barcodeFormatName(format);
Uint32List get bytes => data.cast<Uint32>().asTypedList(length);
Uint32List get bytes {
final Pointer<Uint32> ptr = data.cast<Uint32>();
final Uint32List bytes = ptr.asTypedList(length);
// TODO: Crashes when trying to use 'bytes'. Only on iOS device. Need help to fix.
debugPrint(bytes.toString());
return bytes;
}
String get errorMessage => error.cast<Utf8>().toDartString();
}

Loading…
Cancel
Save