diff --git a/thermion_flutter/thermion_flutter/lib/thermion/widgets/thermion_widget.dart b/thermion_flutter/thermion_flutter/lib/thermion/widgets/thermion_widget.dart index ed77023b..c903e7a4 100644 --- a/thermion_flutter/thermion_flutter/lib/thermion/widgets/thermion_widget.dart +++ b/thermion_flutter/thermion_flutter/lib/thermion/widgets/thermion_widget.dart @@ -3,14 +3,18 @@ import 'dart:math'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:thermion_flutter/thermion/widgets/thermion_widget_web.dart'; +import 'package:thermion_flutter/thermion/widgets/transparent_filament_widget.dart'; +import 'package:thermion_flutter_platform_interface/thermion_flutter_platform_interface.dart'; import 'dart:async'; import 'package:thermion_flutter_platform_interface/thermion_flutter_texture.dart'; import 'package:thermion_flutter/thermion_flutter.dart'; +import 'package:thermion_flutter_web/thermion_flutter_web_options.dart'; import 'resize_observer.dart'; class ThermionWidget extends StatefulWidget { final ThermionViewer viewer; + final ThermionFlutterOptions? options; /// /// The content to render before the texture widget is available. @@ -18,7 +22,8 @@ class ThermionWidget extends StatefulWidget { /// final Widget? initial; - const ThermionWidget({Key? key, this.initial, required this.viewer}) + const ThermionWidget( + {Key? key, this.initial, required this.viewer, this.options}) : super(key: key); @override @@ -43,7 +48,7 @@ class _ThermionWidgetState extends State { } }); var dpr = MediaQuery.of(context).devicePixelRatio; - + var size = ((context.findRenderObject()) as RenderBox).size; _texture = await ThermionFlutterPlugin.createTexture( size.width, size.height, 0, 0, dpr); @@ -60,7 +65,7 @@ class _ThermionWidgetState extends State { Future _resizeTexture(Size newSize) async { _resizeTimer?.cancel(); - _resizeTimer = Timer(Duration(milliseconds: 500), () async { + _resizeTimer = Timer(const Duration(milliseconds: 500), () async { if (_resizing || !mounted) { return; } @@ -74,8 +79,8 @@ class _ThermionWidgetState extends State { var dpr = MediaQuery.of(context).devicePixelRatio; - _texture = await ThermionFlutterPlugin.resizeTexture(oldTexture!, - (dpr * newSize.width).ceil(), (dpr * newSize.height).ceil(), 0, 0); + _texture = await ThermionFlutterPlugin.resizeTexture( + oldTexture!, newSize.width.ceil(), newSize.height.ceil(), 0, 0, dpr); setState(() {}); _resizing = false; }); @@ -88,7 +93,9 @@ class _ThermionWidgetState extends State { return widget.initial ?? Container(color: Colors.red); } return ResizeObserver( - onResized: _resizeTexture, child: ThermionWidgetWeb()); + onResized: _resizeTexture, + child: ThermionWidgetWeb( + options: widget.options! as ThermionFlutterWebOptions)); } if (_texture?.usesBackingWindow == true) { @@ -127,18 +134,3 @@ class _ThermionWidgetState extends State { ])); } } - -class TransparencyPainter extends CustomPainter { - @override - void paint(Canvas canvas, Size size) { - canvas.drawRect( - Rect.fromLTWH(0, 0, size.width, size.height), - Paint() - ..blendMode = BlendMode.clear - ..color = const Color(0x00000000), - ); - } - - @override - bool shouldRepaint(covariant CustomPainter oldDelegate) => false; -}