Fix image support for web

pull/1613/head
Ellet 1 year ago
parent f508a06170
commit fd2ffcb22c
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 4
      CHANGELOG.md
  2. 6
      example/lib/presentation/quill/samples/quill_images_sample.dart
  3. 8
      flutter_quill_extensions/lib/embeds/widgets/image.dart
  4. 11
      flutter_quill_extensions/lib/flutter_quill_extensions.dart

@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## 9.0.3
* Flutter Quill Extensions:
* Fix file image support for web image emebed builder
## 9.0.2 ## 9.0.2
* Remove unused properties in the `QuillToolbarSelectHeaderStyleDropdownButton` * Remove unused properties in the `QuillToolbarSelectHeaderStyleDropdownButton`
* Fix the `QuillSimpleToolbar` when `useMaterial3` is false, please upgrade to the latest version of flutter for better support * Fix the `QuillSimpleToolbar` when `useMaterial3` is false, please upgrade to the latest version of flutter for better support

@ -12,8 +12,10 @@ final quillImagesSample = [
{'insert': '\n'}, {'insert': '\n'},
{ {
'insert': { 'insert': {
'image': 'image': true
'https://helpx.adobe.com/content/dam/help/en/photoshop/using/convert-color-image-black-white/jcr_content/main-pars/before_and_after/image-before/Landscape-Color.jpg' ? 'https://upload.wikimedia.org/wikipedia/commons/b/b6/Image_created_with_a_mobile_phone.png'
// ignore: dead_code
: 'https://helpx.adobe.com/content/dam/help/en/photoshop/using/convert-color-image-black-white/jcr_content/main-pars/before_and_after/image-before/Landscape-Color.jpg'
}, },
'attributes': { 'attributes': {
'width': '250', 'width': '250',

@ -1,6 +1,7 @@
import 'dart:convert'; import 'dart:convert' show base64;
import 'dart:io' show File; import 'dart:io' show File;
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart'; import 'package:flutter_quill/flutter_quill.dart';
import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view.dart';
@ -53,6 +54,11 @@ ImageProvider getImageProviderByImageSource(
if (imageSource.startsWith(assetsPrefix)) { if (imageSource.startsWith(assetsPrefix)) {
return AssetImage(imageSource); return AssetImage(imageSource);
} }
// File image
if (kIsWeb) {
return NetworkImage(imageSource);
}
return FileImage(File(imageSource)); return FileImage(File(imageSource));
} }

@ -112,11 +112,12 @@ class FlutterQuillEmbeds {
/// [QuillEditorWebVideoEmbedBuilder] is the embed builder for handling /// [QuillEditorWebVideoEmbedBuilder] is the embed builder for handling
/// videos iframe on the web. /// videos iframe on the web.
/// ///
static List<EmbedBuilder> editorWebBuilders( static List<EmbedBuilder> editorWebBuilders({
{QuillEditorImageEmbedConfigurations? imageEmbedConfigurations = QuillEditorImageEmbedConfigurations? imageEmbedConfigurations =
const QuillEditorImageEmbedConfigurations(), const QuillEditorImageEmbedConfigurations(),
QuillEditorWebVideoEmbedConfigurations? videoEmbedConfigurations = QuillEditorWebVideoEmbedConfigurations? videoEmbedConfigurations =
const QuillEditorWebVideoEmbedConfigurations()}) { const QuillEditorWebVideoEmbedConfigurations(),
}) {
if (!kIsWeb) { if (!kIsWeb) {
throw UnsupportedError( throw UnsupportedError(
'The editorsWebBuilders() is only for web, please use editorBuilders() ' 'The editorsWebBuilders() is only for web, please use editorBuilders() '

Loading…
Cancel
Save