Browse Source

Add prop `size`&`logoSize` 4 QRCodeWithLogo

melon.yin 2 years ago
parent
commit
f1b020fbfb
3 changed files with 26 additions and 10 deletions
  1. 0 0
      .flutter-plugins-dependencies
  2. 25 9
      lib/src/qrcode_withlogo.dart
  3. 1 1
      pubspec.yaml

File diff suppressed because it is too large
+ 0 - 0
.flutter-plugins-dependencies


+ 25 - 9
lib/src/qrcode_withlogo.dart

@@ -1,27 +1,43 @@
 import 'dart:async';
 import 'dart:ui' as ui;
 
-import 'package:fis_lib_qrcode/src/custom_qrcode_builder.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-// ignore: directives_ordering
 import 'package:fis_lib_qrcode/qr_flutter.dart';
+import 'package:fis_lib_qrcode/src/custom_qrcode_builder.dart';
 import 'package:fis_ui/index.dart';
+import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 
 /// 带logo的二维码
 class QRCodeWithLogo extends StatefulWidget implements FWidget {
+  /// 二维码数据
   final String qrData;
+
+  /// 二维码说明
   final String? codeStatement;
+
+  /// 操作说明
   final String? operationStatement;
+
+  /// 操作回调
   final void Function()? operationSuccessCallback;
 
-  QRCodeWithLogo(
+  /// 尺寸
+  final double size;
+
+  /// logo尺寸
+  final double? logoSize;
+
+  ///带Logo的二维码
+  const QRCodeWithLogo(
     this.qrData, {
+    Key? key,
     this.codeStatement = "QRCodeStatement",
     this.operationStatement = "QRCodeOperationStatement",
     this.operationSuccessCallback,
-  });
+    this.size = 280,
+    this.logoSize,
+  }) : super(key: key);
+
   @override
   _QRCodeWithLogoState createState() => _QRCodeWithLogoState();
 }
@@ -32,7 +48,8 @@ class _QRCodeWithLogoState extends State<QRCodeWithLogo> {
     final qrFutureBuilder = CustomFutureBuilder<ui.Image>(
       future: _loadOverlayImage(),
       builder: (ctx, snapshot) {
-        final size = 280.0;
+        final size = widget.size;
+        final logoSize = widget.logoSize ?? size / 5;
         if (!snapshot.hasData) {
           return Container(width: size, height: size);
         }
@@ -49,10 +66,9 @@ class _QRCodeWithLogoState extends State<QRCodeWithLogo> {
               dataModuleShape: QrDataModuleShape.square,
               color: Colors.black,
             ),
-            // size: 320.0,
             embeddedImage: snapshot.data,
             embeddedImageStyle: QrEmbeddedImageStyle(
-              size: Size.square(60),
+              size: Size.square(logoSize),
             ),
           ),
         );

+ 1 - 1
pubspec.yaml

@@ -6,7 +6,7 @@ version: 4.0.1
 homepage: https://github.com/theyakka/qr.flutter
 
 environment:
-  sdk: ">=2.12.0 <3.0.0"
+  sdk: ">=2.18.2 <3.0.0"
   flutter: ">=1.16.0"
 
 dependency_overrides:

Some files were not shown because too many files changed in this diff