【发布时间】:2020-04-16 14:14:52
【问题描述】:
将图片转换成:
final prefs = await SharedPreferences.getInstance();
var image = ((prefs.getString('photo')));
var send = {'name': usu, 'email': email, 'image': photo};
在小部件中:
Widget _buildDrawer(BuildContext context) { return FutureBuilder<Map>(
future: getFutureDates(), // function where you call your api
builder: (BuildContext context, AsyncSnapshot<Map> snapshot) {
if(!snapshot.hasData) {
return Center(child: CircularProgressIndicator());
} else {
Uint8List profile = base64.decode(snapshot.data['image']); new UserAccountsDrawerHeader(
accountName: new Text((json.encode(snapshot.data['name']).toString().replaceAll('"', ''))),
accountEmail: new Text((json.encode(snapshot.data['email']).toString().replaceAll('"', ''))),
currentAccountPicture: new CircleAvatar(
backgroundImage: MemoryImage((profile)),
),
), } }
姓名和邮箱没问题,但是照片给我一个错误:
无效字符(在字符 呃 5)
data:image/png;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBw8PDw8PDxAPDw4PD...
【问题讨论】:
-
请更新标题和文字。很难接受你的问题