changed firebase storage folder name. now includes uid's
This commit is contained in:
+9
-3
@@ -129,12 +129,18 @@ class _AddScreenState extends State<AddScreen> {
|
|||||||
|
|
||||||
Future<String> uploadImageToFirebaseStorage(
|
Future<String> uploadImageToFirebaseStorage(
|
||||||
File imageFile, String collectionName) async {
|
File imageFile, String collectionName) async {
|
||||||
|
String? userId = FirebaseAuth.instance.currentUser?.uid;
|
||||||
|
if (userId != null) {
|
||||||
Reference ref = FirebaseStorage.instance
|
Reference ref = FirebaseStorage.instance
|
||||||
.ref()
|
.ref()
|
||||||
.child("$collectionName/${DateTime.now().toString()}");
|
.child("$collectionName/$userId/${DateTime.now().toString()}");
|
||||||
UploadTask uploadTask = ref.putFile(imageFile);
|
UploadTask uploadTask = ref.putFile(imageFile);
|
||||||
return await (await uploadTask).ref.getDownloadURL();
|
return await (await uploadTask).ref.getDownloadURL();
|
||||||
|
} else {
|
||||||
|
throw Exception('Cannot upload without user ID');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -248,7 +254,8 @@ class _AddScreenState extends State<AddScreen> {
|
|||||||
? Expanded(
|
? Expanded(
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
double imageHeight = max(0, constraints.maxHeight - keyboardHeight);
|
double imageHeight =
|
||||||
|
max(0, constraints.maxHeight - keyboardHeight);
|
||||||
return Container(
|
return Container(
|
||||||
height: imageHeight,
|
height: imageHeight,
|
||||||
child: Image.file(_imageFile!),
|
child: Image.file(_imageFile!),
|
||||||
@@ -256,7 +263,6 @@ class _AddScreenState extends State<AddScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
: Container(
|
: Container(
|
||||||
height: 200.0,
|
height: 200.0,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|||||||
Reference in New Issue
Block a user