flutter camera setfocuspoint code example

Example 1: how to make event take camera in flutter

Widget _cameraTogglesRowWidget() {
final List<Widget> toggles = <Widget>[];

if (cameras.isEmpty) {
  return const Text('No camera found');
} else {
  for (CameraDescription cameraDescription in cameras) {
    toggles.add(
      SizedBox(
        width: 90.0,
        child: RadioListTile<CameraDescription>(
          title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
          groupValue: controller?.description,
          value: cameraDescription,
          onChanged: controller != null && controller.value.isRecordingVideo
              ? null
              : onNewCameraSelected,
        ),
      ),
    );
  }
}

Example 2: nodeFocus flutter

FocusNode focusNode;

void initState() {
  focusNode = new FocusNode();

  // listen to focus changes
  focusNode.addListener(() => print('focusNode updated: hasFocus: ${focusNode.hasFocus}')); 
}

void setFocus() {
  FocusScope.of(context).requestFocus(focusNode);
}

Widget build() {
  return
  ...
  new TextField(focusNode: focusNode, ...);
}

Tags:

Misc Example