change removeBase64Header to _standardizeImageUrl and format code

pull/107/head
Yahia 4 years ago
parent b4dbf56c73
commit 748316f436
  1. 8
      lib/widgets/editor.dart

@ -93,8 +93,8 @@ abstract class RenderAbstractEditor {
void selectPosition(SelectionChangedCause cause); void selectPosition(SelectionChangedCause cause);
} }
String removeBase64Header(String url){ String _standardizeImageUrl(String url) {
if(url.contains("base64")){ if (url.contains("base64")) {
return url.split(",")[1]; return url.split(",")[1];
} }
return url; return url;
@ -103,7 +103,7 @@ String removeBase64Header(String url){
Widget _defaultEmbedBuilder(BuildContext context, leaf.Embed node) { Widget _defaultEmbedBuilder(BuildContext context, leaf.Embed node) {
switch (node.value.type) { switch (node.value.type) {
case 'image': case 'image':
String imageUrl = removeBase64Header(node.value.data); String imageUrl = _standardizeImageUrl(node.value.data);
return imageUrl.startsWith('http') return imageUrl.startsWith('http')
? Image.network(imageUrl) ? Image.network(imageUrl)
: isBase64(imageUrl) : isBase64(imageUrl)
@ -420,7 +420,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
if (getEditor()!.widget.readOnly && segment.value is BlockEmbed) { if (getEditor()!.widget.readOnly && segment.value is BlockEmbed) {
BlockEmbed blockEmbed = segment.value as BlockEmbed; BlockEmbed blockEmbed = segment.value as BlockEmbed;
if (blockEmbed.type == 'image') { if (blockEmbed.type == 'image') {
final String imageUrl = removeBase64Header(blockEmbed.data); final String imageUrl = _standardizeImageUrl(blockEmbed.data);
Navigator.push( Navigator.push(
getEditor()!.context, getEditor()!.context,
MaterialPageRoute( MaterialPageRoute(

Loading…
Cancel
Save