按钮点击后无法打开相机



我想使用按钮点击打开相机。我也用过GestureDetectorInkWell。但是它不工作。

Container(
height: double.infinity,
width: double.infinity,
color: Color(0xff201b51),
child: Stack(
children: [
Center(
child: Container(
color: Colors.black,
child: isOk
? ElevatedButton(
onPressed: () {
openCamera(context);
print("tapped");
},
child: Text(
"Tap",
style: TextStyle(color: Colors.white),
),
)
: Container(
),
),
),
],
),
),

如果我使用openCamera而不使用按钮,点击它的工作。但是我想用按钮打开它点击

Widget openCamera(BuildContext context) {
return Column(
children: <Widget>[
Expanded(
child: VisibilityDetector(
key: Key("unique key"),
onVisibilityChanged: (VisibilityInfo info) {
if (info.visibleFraction == 0) {
} else {
_scaned = false;
_controller.startCamera(onScan);
}
},
child: Padding(
padding: EdgeInsets.all(10),
child: QrReaderView(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height - 120,
callback: (container) {
this._controller = container;
_controller.startCamera(onScan);
},
)),
),
)
],
);
}

使用这个小部件:^0.10.0