Skip to main content
borro datos sensibles
Origen Enlace

Desde flutter

class QRPlatformChannel {
  static const platform = MethodChannel('app.nodriza_appexample/qr_platform_channel');

  Future<void> lectorPDA() async {
    try {
      var result = await platform.invokeMethod('lector_qr');
      print(result);
    } catch (e) {
      // log.w(e);
    }
  }
}
public class MainActivity extends FlutterActivity {

    private static final String CHANNEL = "app.nodriza_appexample/qr_platform_channel";
    // Barcode2D barcode2D;
    BarcodeUtility barcodeUtility = null;

    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        super.configureFlutterEngine(flutterEngine);
        new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
                .setMethodCallHandler(
                        (call, result) -> {
                            if (call.method.equals("lector_qr")) {
                                barcodeUtility = BarcodeUtility.getInstance();
                                barcodeUtility.setOutputMode(this, 0);
                                barcodeUtility.open(this, BarcodeUtility.ModuleType.BARCODE_2D);
                                barcodeUtility.enablePlaySuccessSound(this, true);
                                barcodeUtility.enableContinuousScan(this, false);
                                barcodeUtility.enableEnter(this, false);
                                barcodeUtility.enableVibrate(this, true);
                                result.success("Configurar PDA");
                            } else {

                                result.notImplemented();
                            }
                        });
    }

}

class QRPlatformChannel {
  static const platform = MethodChannel('app.nodriza_app/qr_platform_channel');

  Future<void> lectorPDA() async {
    try {
      var result = await platform.invokeMethod('lector_qr');
      print(result);
    } catch (e) {
      // log.w(e);
    }
  }
}
public class MainActivity extends FlutterActivity {

    private static final String CHANNEL = "app.nodriza_app/qr_platform_channel";
    // Barcode2D barcode2D;
    BarcodeUtility barcodeUtility = null;

    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        super.configureFlutterEngine(flutterEngine);
        new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
                .setMethodCallHandler(
                        (call, result) -> {
                            if (call.method.equals("lector_qr")) {
                                barcodeUtility = BarcodeUtility.getInstance();
                                barcodeUtility.setOutputMode(this, 0);
                                barcodeUtility.open(this, BarcodeUtility.ModuleType.BARCODE_2D);
                                barcodeUtility.enablePlaySuccessSound(this, true);
                                barcodeUtility.enableContinuousScan(this, false);
                                barcodeUtility.enableEnter(this, false);
                                barcodeUtility.enableVibrate(this, true);
                                result.success("Configurar PDA");
                            } else {

                                result.notImplemented();
                            }
                        });
    }

}

Desde flutter

class QRPlatformChannel {
  static const platform = MethodChannel('app.example/qr_platform_channel');

  Future<void> lectorPDA() async {
    try {
      var result = await platform.invokeMethod('lector_qr');
      print(result);
    } catch (e) {
      // log.w(e);
    }
  }
}
public class MainActivity extends FlutterActivity {

    private static final String CHANNEL = "app.example/qr_platform_channel";
    // Barcode2D barcode2D;
    BarcodeUtility barcodeUtility = null;

    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        super.configureFlutterEngine(flutterEngine);
        new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
                .setMethodCallHandler(
                        (call, result) -> {
                            if (call.method.equals("lector_qr")) {
                                barcodeUtility = BarcodeUtility.getInstance();
                                barcodeUtility.setOutputMode(this, 0);
                                barcodeUtility.open(this, BarcodeUtility.ModuleType.BARCODE_2D);
                                barcodeUtility.enablePlaySuccessSound(this, true);
                                barcodeUtility.enableContinuousScan(this, false);
                                barcodeUtility.enableEnter(this, false);
                                barcodeUtility.enableVibrate(this, true);
                                result.success("Configurar PDA");
                            } else {

                                result.notImplemented();
                            }
                        });
    }

}

Origen Enlace

Existe la forma de interactuar con la capa nativa desde flutter, y es usando MethodChannel. Lo que significa que si quieres implementar un sdk para android, lo puedes hacer de costumbre, pero debes enviar la información a la capa de flutter. Ahora yo te aconsejo que le des una vuelta a las bibliotecas existentes para satisfacer tus requerimientos, ya que de esa forma puedes encontrar soluciones para los distintos sistemas que compilaras.

Mira te doy un ejemplo En este ejemplo yo implemente un sdk de un PDA para configurar lector y demases

class QRPlatformChannel {
  static const platform = MethodChannel('app.nodriza_app/qr_platform_channel');

  Future<void> lectorPDA() async {
    try {
      var result = await platform.invokeMethod('lector_qr');
      print(result);
    } catch (e) {
      // log.w(e);
    }
  }
}

Y desde android

public class MainActivity extends FlutterActivity {

    private static final String CHANNEL = "app.nodriza_app/qr_platform_channel";
    // Barcode2D barcode2D;
    BarcodeUtility barcodeUtility = null;

    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        super.configureFlutterEngine(flutterEngine);
        new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
                .setMethodCallHandler(
                        (call, result) -> {
                            if (call.method.equals("lector_qr")) {
                                barcodeUtility = BarcodeUtility.getInstance();
                                barcodeUtility.setOutputMode(this, 0);
                                barcodeUtility.open(this, BarcodeUtility.ModuleType.BARCODE_2D);
                                barcodeUtility.enablePlaySuccessSound(this, true);
                                barcodeUtility.enableContinuousScan(this, false);
                                barcodeUtility.enableEnter(this, false);
                                barcodeUtility.enableVibrate(this, true);
                                result.success("Configurar PDA");
                            } else {

                                result.notImplemented();
                            }
                        });
    }

}