I'm using image_picker pub_link
for capturing images from the camera. sometimes my app restarts while capturing images from the camera.
this happens randomly not always.
also when I run on an android device it works fine
only on mobile web browser issue is generated
Please help with this issue. Thank you in advance.
here is my code
class NewSurveyScreen1 extends StatefulWidget {
const NewSurveyScreen1({Key? key}) : super(key: key);
@override
State<NewSurveyScreen1> createState() => _NewSurveyScreen1State();
}
class _NewSurveyScreen1State extends State<NewSurveyScreen1> {
File? _image;
Future<void> getImage()async {
XFile? image = await ImagePicker().pickImage(source: ImageSource.camera);
if(image==null) {
return;
}
File imageTeam = File(image.path);
setState(() {
_image = imageTeam;
});
}
@override
void initState() {
log.info("init called in screen1");
// TODO: implement initState
setValueToNA();
super.initState();
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
log.info("will pop scope screen 1");
setValueToNA();
return true;
},
child: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: const Text(
"Survey",
style: TextStyle(color: Colors.black),
),
backgroundColor: Colors.white,
leading: InkWell(
onTap: () {
setValueToNA();
context.vxNav.pop();
// Navigator.pop(context);
},
child: Container(
margin: const EdgeInsets.all(12),
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: AppColors.primaryColor,
),
child: const Icon(Icons.arrow_back_outlined)),
),
),
body: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(15),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
width: 100,
height: 100,
child: InkWell(
onTap: () {
getImage();
},
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: _image==null?Image.asset(
"images/sampel_camera.png",
width: 100,
height: 100,
):Image.network(
_image!.path,
width: 100,
height: 100,
),
),
),
)
],
),
),
),
),
);
}
}