【问题标题】:How to put space between barcode and text using barcode widget package?如何使用条形码小部件包在条形码和文本之间放置空格?
【发布时间】:2021-01-26 02:51:52
【问题描述】:

正如您在图像中看到的那样,条形码和数据文本没有空间,我不知道如何在我使用的这个条形码小部件中放置空间barcode widget

这是我的代码,我需要使用 code39 类型的条形码

class Barcode extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
  return Column(
  children: [
    BarcodeWidget(
      barcode: Barcode.code39(),
      data: '0912658792',
      width: size(480),
      height: size(120),
      margin: EdgeInsets.only(
        bottom: size(60),
      ),
    ),
    BarcodeWidget(
      barcode: Barcode.code39(),
      data: '195795296',
      width: size(480),
      height: size(120),
      margin: EdgeInsets.only(bottom: size(60)),
    ),
    BarcodeWidget(
      barcode: Barcode.code39(),
      data: '4952687794',
      width: size(480),
      height: size(120),
      margin: EdgeInsets.only(bottom: size(60)),
    ),
  ],
);
}
}`

如果有人帮助我,我真的很感激,或者向我推荐其他可以在条形码下放置空间的条形码包,谢谢。

【问题讨论】:

    标签: flutter dart barcode


    【解决方案1】:

    您可以在不同的 BarcodeWidget 实例之间使用 SizedBox。

    ... (your earlier code here)
    ...
    children: [
        BarcodeWidget(
          barcode: Barcode.code39(),
          data: '0912658792',
          width: size(480),
          height: size(120),
          margin: EdgeInsets.only(
            bottom: size(60),
          ),
        ),
        SizedBox(
          height: 40,
        ),
        BarcodeWidget(
          barcode: Barcode.code39(),
          data: '195795296',
          width: size(480),
          height: size(120),
          margin: EdgeInsets.only(bottom: size(60)),
        ),
    ...
    ...
    

    【讨论】:

    • 不,我想要的是条形码和条形码下数据之间的空间,而不是每个条形码小部件之间的空间
    • 这可能是条码规范的一部分,如果不使标准失效,则无法更改。
    【解决方案2】:
    Use This:    
    
    class Barcode extends StatelessWidget {
          @override
          Widget build(BuildContext context) {
          return Column(
          children: [
            BarcodeWidget(
              barcode: Barcode.code39(),
              data: '\n 0912658792',
              width: size(480),
              height: size(120),
              margin: EdgeInsets.only(
                bottom: size(60),
                top: size(60)
              ),
            ),
            BarcodeWidget(
              barcode: Barcode.code39(),
              data: '\n 195795296',
              width: size(480),
              height: size(120),
              margin: EdgeInsets.only(bottom: size(60),top: size(60)),
            ),
            BarcodeWidget(
              barcode: Barcode.code39(),
              data: '\n 4952687794',
              width: size(480),
              height: size(120),
              margin: EdgeInsets.only(bottom: size(60),top: size(60)),
            ),
          ],
        );
        }
        }`
    

    【讨论】:

    • 此边距适用于整个条形码小部件,而不仅仅是文本小部件,所以如果我使用它,条形码和条形码下的数据文本不会改变
    • 我也编辑了我的答案,请检查这个答案
    【解决方案3】:

    我知道答案了

     BarcodeWidget(
      barcode: Barcode.code39(),
      data: '195795296',
      width: size(480),
      height: size(120),
      margin: EdgeInsets.only(bottom: size(60)),
      style: TextStyle(height: 2.0),
    ),
    

    添加带有高度的样式以获得我想要的空间

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-17
      • 1970-01-01
      • 1970-01-01
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      • 2018-05-06
      • 2017-03-09
      相关资源
      最近更新 更多