Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

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

Lucas.Xu271f781ccea7
diff --git a/frontend/appflowy_flutter/lib/shared/appflowy_network_image.dart b/frontend/appflowy_flutter/lib/shared/appflowy_network_image.dart
index 4d89e4eef3..72c6be583e 100644
--- a/frontend/appflowy_flutter/lib/shared/appflowy_network_image.dart
+++ b/frontend/appflowy_flutter/lib/shared/appflowy_network_image.dart
@@ -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;
}