I'm using image picker to get the image , and once it's uploaded , I'd like to pass and display it on a different screen. now I'm getting this error
type 'String' is not a subtype of type 'File'
First screen :
void _openCamera(BuildContext context) async {
final pickedFile = await ImagePicker().getImage(
source: ImageSource.camera,
);
Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => second(image: pickedFile)));
}
second screen :
class second extends StatelessWidget {
const second({
Key? key,
this.image,
}) : super(key: key);
final image;
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.all(16),
child: Card(child: Image.file((image!.path))))),
bottomNavigationBar: BottomAppBar(
color: Colors.white,
),
floatingActionButton: const FloatingActionButton(onPressed: null),
);
}
}