【问题标题】:I want _scanQR() function is to e executed whenever my flutter app is opened before any UI setup我希望在任何 UI 设置之前打开我的颤振应用程序时执行 _scanQR() 函数
【发布时间】:2019-06-06 11:13:28
【问题描述】:

我正在 Flutter 中制作条形码扫描仪应用程序
跟随_scanQR()函数打开相机并扫描条形码并将结果存储在qrResult String中。
我希望在没有任何按钮 onPress 事件的情况下打开我的应用程序并且在扫描条形码后应该设置 GUI 时执行此功能。

 Future _scanQR() async {
      String qrResult = await BarcodeScanner.scan();
      setState(() {
        result = qrResult;
      });
  }

【问题讨论】:

    标签: flutter dart barcode flutter-layout


    【解决方案1】:

    在初始化状态下调用函数。确保你有一个有状态的

    @override
      void initState() {
        super.initState();
        _scanQR();
      }
    
    

    【讨论】:

      猜你喜欢
      • 2021-12-19
      • 2020-05-11
      • 1970-01-01
      • 2021-03-05
      • 2020-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-03
      相关资源
      最近更新 更多