Created
June 24, 2020 12:47
-
-
Save Anirudhk07/7098562bad53ecbdb27b566cd54d1810 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget build(BuildContext context) { | |
Future getImage() async { | |
var image = await ImagePicker.pickImage(source: ImageSource.gallery); | |
setState(() { | |
_image = image; | |
print('Image Path $_image'); | |
}); | |
} | |
Future uploadPic(BuildContext context) async{ | |
String fileName = basename(_image.path); | |
StorageReference firebaseStorageRef = FirebaseStorage.instance.ref().child(fileName); | |
StorageUploadTask uploadTask = firebaseStorageRef.putFile(_image); | |
StorageTaskSnapshot taskSnapshot=await uploadTask.onComplete; | |
setState(() { | |
print("Profile Picture uploaded"); | |
Scaffold.of(context).showSnackBar(SnackBar(content: Text('Profile Picture Uploaded'))); | |
}); | |
} |
I had the same issue, they failed to tell you to use the following import package:
import 'package:path/path.dart';
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you please share the basename function. Thank you.