Merge pull request #33 from yaso-meth/bug-profile-pictire-update-fix
Bug-profile-pictire-update-fix
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../main.dart';
|
import '../../main.dart';
|
||||||
@@ -69,18 +71,54 @@ class _MIHProfilePictureState extends State<MIHProfilePicture> {
|
|||||||
type: FileType.custom,
|
type: FileType.custom,
|
||||||
allowedExtensions: ['jpg', 'png'],
|
allowedExtensions: ['jpg', 'png'],
|
||||||
);
|
);
|
||||||
if (result == null) return;
|
// print(
|
||||||
final selectedFile = result.files.first;
|
// "Platform: ${MzanziInnovationHub.of(context)!.theme.getPlatform()}");
|
||||||
setState(() {
|
if (MzanziInnovationHub.of(context)!.theme.getPlatform() ==
|
||||||
widget.onChange(selectedFile);
|
"Web") {
|
||||||
widget.proPic = selectedFile;
|
if (result == null) return;
|
||||||
//print("MIH Profile Picture: ${widget.proPic}");
|
final selectedFile = result.files.first;
|
||||||
propicPreview = MemoryImage(widget.proPic!.bytes!);
|
setState(() {
|
||||||
});
|
widget.onChange(selectedFile);
|
||||||
|
widget.proPic = selectedFile;
|
||||||
|
//print("MIH Profile Picture: ${widget.proPic}");
|
||||||
|
propicPreview = MemoryImage(widget.proPic!.bytes!);
|
||||||
|
});
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.proPicController.text = selectedFile.name;
|
widget.proPicController.text = selectedFile.name;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// print(
|
||||||
|
// "================\nHere for Android\n========================");
|
||||||
|
if (result != null) {
|
||||||
|
// print("here 1");
|
||||||
|
File file = File(result.files.single.path!);
|
||||||
|
PlatformFile? androidFile = PlatformFile(
|
||||||
|
path: file.path,
|
||||||
|
name: file.path.split('/').last,
|
||||||
|
size: file.lengthSync(),
|
||||||
|
bytes: await file.readAsBytes(), // Read file bytes
|
||||||
|
//extension: fileExtension,
|
||||||
|
);
|
||||||
|
// print("here 2");
|
||||||
|
setState(() {
|
||||||
|
// print("here 3");
|
||||||
|
widget.onChange(androidFile);
|
||||||
|
// print("here 4");
|
||||||
|
widget.proPic = androidFile;
|
||||||
|
// print("here 5");
|
||||||
|
//print("MIH Profile Picture: ${widget.proPic}");
|
||||||
|
//print("bytes: ${widget.proPic!.bytes!}");
|
||||||
|
propicPreview = FileImage(file);
|
||||||
|
});
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
widget.proPicController.text = widget.proPic!.name;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// User canceled the picker
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.edit),
|
icon: const Icon(Icons.edit),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -218,8 +218,12 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> submitForm() async {
|
Future<void> submitForm() async {
|
||||||
|
// print("============\nsubmiit form\n=================");
|
||||||
if (isFieldsFilled()) {
|
if (isFieldsFilled()) {
|
||||||
if (oldProPicName != proPicController.text) {
|
if (oldProPicName != proPicController.text) {
|
||||||
|
// print("here 1");
|
||||||
|
// print("Pro File Name: ${proPic!.name}");
|
||||||
|
// print("Pro File Bytes: ${proPic!.bytes}");
|
||||||
await uploadSelectedFile(proPic);
|
await uploadSelectedFile(proPic);
|
||||||
}
|
}
|
||||||
await updateUserApiCall();
|
await updateUserApiCall();
|
||||||
@@ -308,6 +312,13 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// const SizedBox(height: 10.0),
|
||||||
|
// MIHTextField(
|
||||||
|
// controller: proPicController,
|
||||||
|
// hintText: "Pro Pic",
|
||||||
|
// editable: true,
|
||||||
|
// required: true,
|
||||||
|
// ),
|
||||||
const SizedBox(height: 10.0),
|
const SizedBox(height: 10.0),
|
||||||
MIHTextField(
|
MIHTextField(
|
||||||
controller: usernameController,
|
controller: usernameController,
|
||||||
|
|||||||
@@ -346,10 +346,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: file_picker
|
name: file_picker
|
||||||
sha256: "16dc141db5a2ccc6520ebb6a2eb5945b1b09e95085c021d9f914f8ded7f1465c"
|
sha256: c904b4ab56d53385563c7c39d8e9fa9af086f91495dfc48717ad84a42c3cf204
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.1.4"
|
version: "8.1.7"
|
||||||
firebase_core:
|
firebase_core:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ dependencies:
|
|||||||
syncfusion_flutter_core: ^26.2.10
|
syncfusion_flutter_core: ^26.2.10
|
||||||
syncfusion_flutter_pdfviewer: ^26.1.39
|
syncfusion_flutter_pdfviewer: ^26.1.39
|
||||||
universal_html: ^2.2.4
|
universal_html: ^2.2.4
|
||||||
file_picker: ^8.1.4
|
file_picker: ^8.1.7
|
||||||
supertokens_flutter: ^0.6.0
|
supertokens_flutter: ^0.6.0
|
||||||
http: ^1.2.1
|
http: ^1.2.1
|
||||||
google_nav_bar: ^5.0.6
|
google_nav_bar: ^5.0.6
|
||||||
|
|||||||
Reference in New Issue
Block a user