I am building demo of camera(including, taking picture, save in gallery), but I am getting error of RangeError (index): Invalid value: Valid value range is empty: 0 . I tried to solve in different ways but I could not. If you have any solution so, let me know.
Error is occuring because of below code
List<CameraDescription> camera = [];
.
class _CameraScreenState extends State<CameraScreen>
with WidgetsBindingObserver{
_ _ _ _ _ _ _
@override
void initState() {
onNewCameraSelected(camera[0]);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
_ _ _
);
}
}
Thanks in advance.
Seems like you are not getting any data on camera
. You can skip the error like,
if(tasks.isNotEmpty)onNewCameraSelected(camera[0]);
And for N number
if(tasks.length>=n-1)onNewCameraSelected(camera[n]);
Usually RangeError (index): Invalid value: Valid value range is empty: 0 is generated whenever you try to call an empty or null list possible there is no data filed in your List
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.