123456789101112131415161718192021222324252627282930313233343536373839404142 |
- /*
- * QR.Flutter
- * Copyright (c) 2019 the QR.Flutter authors.
- * See LICENSE for distribution and usage details.
- */
- import 'dart:typed_data';
- import 'package:flutter/material.dart';
- import 'package:flutter_test/flutter_test.dart';
- // ignore: directives_ordering
- import 'package:fis_lib_qrcode/qr_flutter.dart';
- void main() {
- testWidgets('QrPainter generates correct image', (tester) async {
- final painter = QrPainter(
- data: 'The painter is this thing',
- version: QrVersions.auto,
- gapless: true,
- errorCorrectionLevel: QrErrorCorrectLevel.L,
- );
- ByteData? imageData;
- await tester.runAsync(() async {
- imageData = await painter.toImageData(600.0);
- });
- final imageBytes = imageData!.buffer.asUint8List();
- final widget = Center(
- child: RepaintBoundary(
- child: Container(
- width: 600,
- height: 600,
- child: Image.memory(imageBytes),
- ),
- ),
- );
- await tester.pumpWidget(widget);
- await tester.pumpAndSettle();
- await expectLater(
- find.byType(RepaintBoundary),
- matchesGoldenFile('./.golden/qr_painter_golden.png'),
- );
- });
- }
|