image support added on web

pull/33/head
rish07 4 years ago committed by singerdmx
parent 7e40cee236
commit 3547e015e4
  1. 2
      app/pubspec.lock
  2. 16
      lib/widgets/editor.dart

@ -82,7 +82,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.7"
version: "0.2.8"
flutter_test:
dependency: "direct dev"
description: flutter

@ -1,5 +1,7 @@
import 'dart:html' as html;
import 'dart:io';
import 'dart:math' as math;
import 'dart:ui' as ui;
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
@ -78,7 +80,19 @@ Widget _defaultEmbedBuilder(BuildContext context, leaf.Embed node) {
switch (node.value.type) {
case 'image':
if (kIsWeb) {
return SizedBox.shrink();
String imageUrl = node.value.data;
ui.platformViewRegistry.registerViewFactory(
imageUrl,
(int viewId) => html.ImageElement()..src = imageUrl,
);
return Container(
constraints: BoxConstraints(maxWidth: 300),
height: MediaQuery.of(context).size.height,
child: HtmlElementView(
viewType: imageUrl,
),
);
}
String imageUrl = node.value.data;
return imageUrl.startsWith('http')

Loading…
Cancel
Save