DavBfr / dart_barcode

Barcode generation library
https://pub.dev/packages/barcode
Apache License 2.0
132 stars 41 forks source link

GestureDetector doesn't work #1

Closed christianarduino closed 4 years ago

christianarduino commented 4 years ago

Using the onTap method of the GestureDetector widget, the gesture is not detected

How I use it:

GestureDetector(
  child: BarcodeWidget(
    data: barData,
    barcode: Barcode.code128(),
    drawText: false,
    height: ScreenUtil().setHeight(55),
    width: ScreenUtil().setWidth(280),
  ),
  onTap: () {
     print("test");
   },
),

Device: LG G6 Android 8.0

Computer: Macbook air 2018

DavBfr commented 4 years ago

This must be something else in your app, there are no reasons for it to not work.

christianarduino commented 4 years ago

I've made several attempts and I don't think it's related to my code

I tried to recreate the error in a simple page with Scaffold widget and the error persists

My code:

import 'package:barcode_widget/barcode_widget.dart';
import 'package:flutter/material.dart';

class Test extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Center(
          child: FittedBox(
            child: GestureDetector(
              child: BarcodeWidget(
                data: "7482734KINDJKF",
                barcode: Barcode.code39(),
              ),
              onTap: () {
                print("test");
              },
            ),
          ),
        ),
      ),
    );
  }
}

This time I tried on an iPhone 11 Pro Max simulator

DavBfr commented 4 years ago

if you wrap the barcode widget with Material() it works.

christianarduino commented 4 years ago

I confirm that using the Material() widget, gestures are detected

DavBfr commented 4 years ago

Fixed in barcode_widget-1.2.2. No need for Material() anymore. Don't hesitate to Buy Me A Coffee.