1
- import 'dart:io ' ;
1
+ import 'dart:typed_data ' ;
2
2
3
3
import 'package:cached_network_image/cached_network_image.dart' ;
4
4
import 'package:flutter/material.dart' ;
@@ -22,7 +22,7 @@ class _EditProfileWidgetState extends State<EditProfileWidget> {
22
22
late TextEditingController nameController;
23
23
late TextEditingController usernameController;
24
24
late TextEditingController statusController;
25
- XFile ? image;
25
+ Uint8List ? image;
26
26
27
27
@override
28
28
void initState () {
@@ -82,24 +82,20 @@ class _EditProfileWidgetState extends State<EditProfileWidget> {
82
82
children: [
83
83
CircleAvatar (
84
84
radius: 40 ,
85
- child: image != null
86
- ? Image .file (File (image! .path))
87
- : CachedNetworkImage (
88
- imageUrl: widget.user.profilePictureUrl ??
89
- defaultProfilePicture,
90
- placeholder: (context, url) =>
91
- const CircularProgressIndicator (),
92
- errorWidget: (context, url, error) =>
93
- const Icon (Icons .error),
94
- ),
85
+ foregroundImage: image != null
86
+ ? MemoryImage (image! ) as ImageProvider
87
+ : CachedNetworkImageProvider (widget.user.profilePictureUrl ??
88
+ defaultProfilePicture),
95
89
),
96
90
const SizedBox (width: 50 ),
97
91
OutlinedButton (
98
92
onPressed: () async {
99
93
final ImagePicker picker = ImagePicker ();
100
- final img = await picker.pickImage (
101
- source: ImageSource .gallery,
102
- );
94
+ final img = await picker
95
+ .pickImage (
96
+ source: ImageSource .gallery,
97
+ )
98
+ .then ((value) => value! .readAsBytes ());
103
99
setState (() {
104
100
image = img;
105
101
});
@@ -152,7 +148,7 @@ class _EditProfileWidgetState extends State<EditProfileWidget> {
152
148
'name' : nameController.text,
153
149
'username' : usernameController.text,
154
150
'status' : statusController.text,
155
- 'image' : image != null ? File ( image! .path) : null ,
151
+ 'image' : image != null ? image : null ,
156
152
'shouldUpdateUsername' :
157
153
usernameController.text != widget.user.username,
158
154
},
0 commit comments