Open Damandroid opened 3 years ago
Hi @Damandroid
Please provide a code that does not use any third-party plugin/package and the complete output of flutter doctor -v
.
Thank you
Here is an example to demonstrate the problem. The error occurs when you navigate to Tab2 the second time.
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:universal_html/html.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: Text('HtmlElementView Test'),
bottom: TabBar(
tabs: [
Tab(text: 'Tab1'),
Tab(text: 'Tab2'),
],
),
),
body: TabBarView(
physics: NeverScrollableScrollPhysics(),
children: [
Tab1(),
Tab2(),
],
),
),
);
}
}
class Tab1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Text('Tab1'),
);
}
}
class Tab2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
final String viewID = 'view1';
// ignore: undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory(
viewID,
(int id) => IFrameElement()
..width = MediaQuery.of(context).size.width.toString()
..height = MediaQuery.of(context).size.height.toString()
..srcdoc = '<html><p>This is an HTML view</p></html>'
..style.border = 'none',
);
return HtmlElementView(
viewType: viewID,
);
}
}
Flutter Doctor Output
[✓] Flutter (Channel beta, 1.25.0-8.1.pre, on Mac OS X 10.15.7 19H114 darwin-x64, locale en-US) • Flutter version 1.25.0-8.1.pre at /Users/martin/fvm/versions/beta • Framework revision 8f89f6505b (6 days ago), 2020-12-15 15:07:52 -0800 • Engine revision 92ae191c17 • Dart version 2.12.0 (build 2.12.0-133.2.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/martin/Library/Android/sdk • Platform android-30, build-tools 29.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.3, Build version 12C33 • CocoaPods version 1.9.3
[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.0) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 45.1.1 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.52.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.14.0
[✓] Connected device (1 available) • Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.88
• No issues found!
The problem does not occur if you use a unique viewID on each call to platformViewRegistry.registerViewFactory.
Reproducible on latest master
channel.
I am still experiencing this issue with Flutter 3.3.4. Basic usage of HtmlElementView results in a crash, is this really only a P4?
Verified this issue using latest versions and observed that the originally reported behavior doesn't occur anymore, but now it throws:
Error: Unexpected null value.
upon navigating from tab1 to tab2 the second time. I also used dart:html import instead of the third party universal_html
package that was originally used, but it gives same error.
This is an HTML view
' ..style.border = 'none', ); return HtmlElementView( viewType: viewID, ); } } ```Updating the issue title to reflect latest behavior.
/cc @yjbanov for thoughts.
Hi, simple use of HTMLElementView is causing issues in my app.
My code is as follows:
Code
``` import 'dart:html'; import 'package:myPackage/constants.dart'; import 'package:myPackage/contentProvider/contentProvider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'dart:html' as html; import 'dart:js' as js; import 'dart:ui' as ui; class Payment extends StatefulWidget { @override _PaymentState createState() => _PaymentState(); } String viewID = "myView"; String urlOnline = "myURL"; String urlLocal = "my localhost url"; bool online = true; class _PaymentState extends StateAnytime I move away from this page I get the following error:
If I press back button on my appear I get the dependency error. Is this a problem with flutter? I have checked other examples online and they have done things in a similar way so I am not sure what the problem is here?
Flutter Doctor Output:
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel master, 1.25.0-5.0.pre.90, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) [✓] Xcode - develop for iOS and macOS (Xcode 12.2) [✓] Chrome - develop for the web [✓] Android Studio (version 4.1) [✓] Connected device (2 available)
• No issues found!