fix: application will raise an error when selecting unsplash image in local mode (#4604)

This commit is contained in:
Lucas.Xu 2024-02-05 21:53:14 +07:00 committed by GitHub
parent ef4bce25d8
commit 271f781cce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:appflowy/shared/custom_image_cache_manager.dart';
import 'package:appflowy/util/string_extension.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
@ -56,7 +57,12 @@ class FlowyNetworkImage extends StatelessWidget {
final header = <String, String>{};
final token = userProfilePB?.token;
if (token != null) {
header['Authorization'] = 'Bearer ${jsonDecode(token)['access_token']}';
try {
final decodedToken = jsonDecode(token);
header['Authorization'] = 'Bearer ${decodedToken['access_token']}';
} catch (e) {
Log.error('unable to decode token: $e');
}
}
return header;
}