| 123456789101112131415161718192021222324252627282930 |
- import 'dart:html';
- import 'dart:ui' as ui;
- import 'package:flutter/cupertino.dart';
- class WebImage extends StatelessWidget {
- String url;
- double width,height;
- double _borderRadius = 0.0;
- WebImage({Key? key,required this.url,required this.width,required this.height,double? borderRadius}) : super(key: key){
- if (borderRadius!=null){
- _borderRadius = borderRadius;
- }
- }
- @override
- Widget build(BuildContext context) {
- String _divId = "web_image_"+DateTime.now().toIso8601String();
- ui.platformViewRegistry.registerViewFactory(
- _divId,
- (int viewId) => ImageElement(src: url)..style.width='100%'..style.height='100%'..style.borderRadius='${_borderRadius}px'..style.objectFit='cover',
- );
- return SizedBox(
- width: width,
- height: height,
- child: HtmlElementView(key: UniqueKey(),
- viewType: _divId,),
- );
- }
- }
|