File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ import 'dart:convert' ;
2+ import 'dart:typed_data' ;
13import 'dart:ui' ;
24
35import 'package:codelessly_api/codelessly_api.dart' ;
@@ -1338,6 +1340,18 @@ extension StringExt on String {
13381340 return path.extension (uri.path).contains ('svg' );
13391341 }
13401342
1343+ bool get isBase64Blob {
1344+ final uri = Uri .tryParse (this );
1345+ if (uri == null ) return false ;
1346+ return uri.scheme == 'data' && uri.path.contains ('base64' );
1347+ }
1348+
1349+ // Assumes [isBase64Blob] is true. Decodes the base64 data and returns it.
1350+ // data:image/gif;base64,<BASE64 CODE>
1351+ Uint8List get base64Data {
1352+ return base64Decode (split (',' )[1 ]);
1353+ }
1354+
13411355 String toJsonPointerPath () {
13421356 final tokens = split (RegExp ('[[.]' ));
13431357 final formatted = tokens.map ((e) => e.replaceAll (']' , '' )).join ('/' );
Original file line number Diff line number Diff line change @@ -223,6 +223,22 @@ class _UltimateImageBuilderState extends State<UltimateImageBuilder> {
223223 );
224224 }
225225
226+ if (url.isBase64Blob) {
227+ return Image .memory (
228+ url.base64Data,
229+ fit: fit,
230+ alignment: alignment,
231+ scale: scale,
232+ width: width,
233+ height: height,
234+ repeat: repeat,
235+ color: widget.color,
236+ colorBlendMode: colorBlendMode,
237+ errorBuilder: (context, _, __) =>
238+ (widget.errorBuilder ?? _defaultErrorBuilder)(context),
239+ );
240+ }
241+
226242 return CachedNetworkImage (
227243 imageUrl: url,
228244 fit: fit,
You can’t perform that action at this time.
0 commit comments