Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

////////////////////////////////////////////// WIDGET‫متغيرات بينحطوا بنفس الصفحة يلي فيها ال‬

final _picker = ImagePicker();


File? _image;

////////////////////////////////////////////// WIDGET‫تابع بينحط بنفس الصفحة يلي فيها ال‬


Future<void> _openImagePicker() async {
final XFile? pickedImage =
await _picker.pickImage(source: ImageSource.gallery);
if (pickedImage != null) {
setState(() {
_image = File(pickedImage.path);
var bytes = _image?.readAsBytesSync();
image64 = base64.encode(bytes!);
});
}
}

/////////////////////////////////////////// WIDGET
Center(
child: TextButton(
onPressed: () {
_openImagePicker();
},
child: _image == null
? CircleAvatar(
radius: 70.0,
backgroundImage: AssetImage('images/avatar.png'),
)
: CircleAvatar(
radius: 70.0,
backgroundImage: FileImage(File(_image!.path)),
),
),
),

////////////////////////////////////////// ‫يلي رح تجي من‬


‫ الباك لصورة مشان بعدين‬STRING ‫هاد التابع للتحويل من ال‬
Uint8List convertBase64Image(String base64String) {
Uint8List _bytes = base64.decode(base64String.split(',').last);
return _bytes;
}

You might also like