Skip to content

Instantly share code, notes, and snippets.

@felangel
Last active April 1, 2021 04:49
Show Gist options
  • Save felangel/112db05e57705f5fcdf588a9fb528eba to your computer and use it in GitHub Desktop.
Save felangel/112db05e57705f5fcdf588a9fb528eba to your computer and use it in GitHub Desktop.
HtmlElementView Transform Bug
import 'dart:html';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late VideoElement _videoElement;
static const _viewType = '_videoElement_';
@override
void initState() {
super.initState();
_videoElement = VideoElement();
ui.platformViewRegistry.registerViewFactory(
_viewType,
(int _) => _videoElement,
);
window.navigator.mediaDevices?.getUserMedia(
<dynamic, dynamic>{'video': true},
).then((stream) {
_videoElement
..autoplay = true
..muted = true
..srcObject = stream
..style.transformOrigin = ''
..style.transform = 'rotateY(180deg)'
..setAttribute('playsinline', '');
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(child: HtmlElementView(viewType: _viewType)),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {},
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment