Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter - type file is not a subtype of type 'imageprovider dynamic '

Tags:

When i select image from image picker i am getting this error type file is not a subtype of type 'imageprovider dynamic '

I tried using stack even though the same error
  class _ProfileState extends State<Profile> {          @override           Widget build(BuildContext context) {             return Scaffold(               appBar: AppBar(                 automaticallyImplyLeading: true,                 title: Text('Profile'),                 centerTitle: true,                 elevation: 10.0,               ),               body: Container(                 decoration: BoxDecoration(                     image: DecorationImage(                         image: _imageFile == null                             ? AssetImage('assets/tom.jpg')                             : _imageFile,                         fit: BoxFit.cover)),                 child: ListView(                   children: <Widget>[                     Container(                       height: MediaQuery.of(context).size.height / 1.4,                     ),                     Card(                       color: Colors.grey.withOpacity(0.1),                       shape: RoundedRectangleBorder(                           borderRadius: BorderRadius.circular(10.0)),                       child: cameraAndEdit(context),                     ),                     Container(                       width: MediaQuery.of(context).size.width,                       color: Colors.white70,                       child: Padding(                         padding: const EdgeInsets.all(8.0),                         child: Column(                           children: <Widget>[                             box(),                             line(color: Colors.deepPurple, lineHeight: 5.0),                             // nameDesignation(),                             infoRow(                                 infoIcon: Icon(Icons.person),                                 infoText: 'Name',                                 detail: 'Tom Cruise',                                 textColor: Colors.black),                             Divider(),                             infoRow(                                 infoIcon: Icon(Icons.location_on),                                 infoText: 'Address',                                 detail: '#9/1 1st main Circle street Bangalore 560-096',                                 textColor: Colors.black),                             Divider(),                             infoRow(                                 infoIcon: Icon(Icons.gesture),                                 infoText: 'Age',                                 detail: '25',                                 textColor: Colors.black),                             Divider(),                             infoRow(                                 infoIcon: Icon(Icons.phone),                                 infoText: 'Phone',                                 detail: '+91 9148046273',                                 textColor: Colors.black),                             line(color: Colors.deepPurple, lineHeight: 5.0),                             box(),                           ],                         ),                       ),                     ),                   ],                 ),               ),             );           } 
like image 454
Rakshith Rakshak Avatar asked Jan 20 '19 11:01

Rakshith Rakshak


1 Answers

   image: _imageFile == null         ? AssetImage('assets/tom.jpg')         : _imageFile, 

should be

   image: _imageFile == null         ? AssetImage('assets/tom.jpg')         : FileImage(_imageFile), 
like image 114
Günter Zöchbauer Avatar answered Oct 05 '22 05:10

Günter Zöchbauer