camera_camera
camera_camera copied to clipboard
I would like to enable the front camera first
I would like to enable the front camera first, but also be able to switch to the rear camera. How do I set it up this way?
late File selfie;
bool camFront = true;
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Column(
children: [
Flexible(
flex: 3,
child: Stack(
children: [
CameraCamera(
onFile: (file) => showPreview(file),
cameraSide: camFront ? CameraSide.back : CameraSide.front,
enableZoom: false,
resolutionPreset: ResolutionPreset.medium,
),
InkWell(
onTap: () {
setState(() {
camFront = !camFront;
});
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Align(
alignment: Alignment.bottomRight,
child: CircleAvatar(
backgroundColor: greenIdent,
child: const Icon(
Icons.flip_camera_ios,
color: Colors.white,
),
),
),
),
)
],
),
),