WEB - Regression - @staticInterop classes should not contain any generative constructors

This issue has been tracked since 2022-11-24.


I upgraded the framework today from 3.0.1 to 3.3.9 today and am having issues building release for Web. I also tried the latest master 3.6.0-7.0.pre.51 and it has the same error. Do you have any ideas what I can try?


Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use 'dart compile js' instead.
Error: `@staticInterop` classes should not contain any generative constructors.
  external _ClipboardItem(dynamic args);
Error: Compilation failed.

Works: 3.0.1
CALL fvm use fb57da5 && CALL fvm flutter build web --release

Doesn't work: 3.3.9 / latest master
flutter build web --release

import 'package:flutter/material.dart';
import 'dart:html';
import 'dart:typed_data';
import 'package:js/js.dart';
import 'package:js/js_util.dart';

void main() {
  runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      home: const MyHomePage(title: 'Flutter Demo Home Page'),

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  State<MyHomePage> createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('You have pushed the button this many times:'),

class ClipboardOperations {
  static void copyPNGImage(Uint8List pngBytes) async {
    final clipboard = window.navigator.clipboard as _Clipboard?;
    if (clipboard == null) {
      print('Error - No Clipboard found');

//DOES not work on Firefox due to limitations in Clipboard API

    final dataMap = <dynamic, dynamic>{
      'image/png': Blob([pngBytes as Uint8List] as List<dynamic>, 'image/png')

    dynamic out = jsify(dataMap);
    final item = _ClipboardItem(out);
    await clipboard.write([item]);

class _ClipboardItem {
  external _ClipboardItem(dynamic args);

class _Clipboard {}

extension _ClipboardImpl on _Clipboard {
  external dynamic _write(List<_ClipboardItem> items);
  Future<void> write(List<_ClipboardItem> items) => promiseToFuture(_write(items) as Object);
flutter doctor
[!] Flutter (Channel master, 3.6.0-7.0.pre.51, on Microsoft Windows [Version 10.0.22598.1], locale en-IE)
    • Flutter version 3.6.0-7.0.pre.51 on channel master at c:\code\flutter
    ! Warning: `flutter` on your path resolves to C:\code\flutter\bin\flutter, which is not inside your current Flutter SDK checkout at
      c:\code\flutter. Consider adding c:\code\flutter\bin to the front of your path.
    ! Warning: `dart` on your path resolves to C:\code\flutter\bin\cache\dart-sdk\bin\dart.exe, which is not inside your current Flutter SDK checkout
      at c:\code\flutter. Consider adding c:\code\flutter\bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a41376ede2 (2 hours ago), 2022-11-24 14:28:34 -0500
    • Engine revision ad21c5adfd
    • Dart version 2.19.0 (build 2.19.0-429.0.dev)
    • DevTools version 2.19.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and

[√] Windows Version (Installed version of Windows is version 10 or higher)

[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[√] Chrome - develop for the web
    • CHROME_EXECUTABLE = c:\code\rocketx\chromecorsarm.bat

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] VS Code (version 1.73.1)
    • VS Code at C:\Users\Rober\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.52.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22598.1]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 107.0.5304.107
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 106.0.1370.37

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 4 categories.
huycozy wrote this answer on 2022-11-25

Hi @zambetpentru I think this issue is caused by implementation. Below is full error message I got when running your sample code:

lib/web_dart2js_115988.dart:78:12: Error: `@staticInterop` classes should not contain any generative constructors.
Use factory constructors instead.
  external _ClipboardItem(dynamic args);
Failed to compile application.

Try updating the code to use external factory, it can run normally:

class _ClipboardItem {
  external factory _ClipboardItem(dynamic args);

Also, you can check this dart-lang issue dart-lang/sdk#48730 as reference. For further questions, please write a comment there or file a new issue on dart-lang/sdk repository for better support.

Closing as this is not a Flutter issue. If you disagree, please write in the comments and I will reopen it. Thank you!

zambetpentru wrote this answer on 2022-11-25

Brilliant thank you! The standard Flutter build didn't give me that extended error message about using the factory.

More Details About Repo
Owner Name flutter
Repo Name flutter
Full Name flutter/flutter
Language Dart
Created Date 2015-03-06
Updated Date 2022-12-07
Star Count 147031
Watcher Count 3560
Fork Count 23915
Issue Count 11300


Issue Title Created Date Updated Date