Skip to content

Padding does not work as expected #104

@hhkkyy

Description

@hhkkyy
import 'package:flutter/material.dart';
import 'package:qr_flutter/qr_flutter.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: Scaffold(
        appBar: AppBar(),
        body: Row(
          children: <Widget>[
            Expanded(child: QrImage(
              data: 'datadatadatadatadatadatadatadatadata',
              padding: EdgeInsets.zero,
            )),
            Expanded(child: QrImage(
              data: 'datadatadatadatadatadatadatadatadata',
              padding: EdgeInsets.all(5),
            )),
            Expanded(child: QrImage(
              data: 'datadatadatadatadatadatadatadatadata',
              padding: EdgeInsets.all(10),
            )),
            Expanded(child: QrImage(
              data: 'datadatadatadatadatadatadatadatadata',
              padding: EdgeInsets.all(15),
            )),
          ],
        ),
      ),
    );
  }
}

image
image

The 2nd qrCode and the 3rd one has different padding but share the 'same' size. I understand that they have different widget size and QrImage resized the image to the same. But this makes it impossible for me to get a qrCode with a size I wanted, it's always resized to some certain size. I think the image should always fit the size of the widget.

What's more, with zero padding, the qrCode overflows the boudary.
In my app this code caused overflow

Container(
  width: 80,
  child: QrImage(
    data: 'datadatadatadatadatadatadatadatadata',
    padding: EdgeInsets.zero,
  ),
),

image

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.1, on Microsoft Windows [Version 10.0.18362.959], locale zh-CN)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[!] Android Studio (version 3.2)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Ultimate Edition (version 2017.3)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code, 64-bit edition (version 1.41.0)
[√] Connected device (1 available

qr_flutter: ^3.0.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixedFixed and will be included in next release

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions