Skip to content

Semantics error on web #174141

@sunarya-thito

Description

@sunarya-thito

Steps to reproduce

  1. Make sure SemanticsBinding.instance.ensureSemantics() is called
  2. Run on web
  3. Spam click the increment button
    Note: It might be hard to reproduce, sometimes it happens, sometimes it doesn't, try pausing between click spams

Expected results

There shouldn't be an error when clicked

Actual results

It causes an error

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  SemanticsBinding.instance.ensureSemantics();
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('You have pushed the button this many times:'),
            Semantics(
              label: 'Counter value',
              value: '$_counter',
              child: Text(
                '$_counter',
                style: Theme.of(context).textTheme.headlineMedium,
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
DartError: Unexpected null value.
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 274:3       throw_
errors.dart:274
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 948:18  nullCheck
operations.dart:948
lib/_engine/engine/pointer_binding.dart 374:39                                    [_debounce]
pointer_binding.dart:374
lib/_engine/engine/pointer_binding.dart 233:7                                     onPointerData
pointer_binding.dart:233
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
operations.dart:118
lib/_engine/engine/pointer_binding.dart 1032:16                                   <fn>
pointer_binding.dart:1032
lib/_engine/engine/pointer_binding.dart 942:7                                     <fn>
pointer_binding.dart:942
lib/_engine/engine/pointer_binding.dart 565:9                                     loggedHandler
pointer_binding.dart:565
dart-sdk/lib/async/zone.dart 1849:54                                              runUnary
zone.dart:1849
dart-sdk/lib/async/zone.dart 1804:26                                              <fn>
zone.dart:1804
dart-sdk/lib/_internal/js_dev_runtime/patch/js_allow_interop_patch.dart 224:27    _callDartFunctionFast1

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.35.1, on Microsoft Windows [Version 10.0.22631.5624], locale en-ID) [625ms]
    • Flutter version 3.35.1 on channel stable at D:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 20f8274939 (6 days ago), 2025-08-14 10:53:09 -0700
    • Engine revision 1e9a811bf8
    • Dart version 3.9.0
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android,
      enable-ios, cli-animations, enable-lldb-debugging

[√] Windows Version (11 Pro 64-bit, 23H2, 2009) [4.2s]

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [1,144ms]
    • Android SDK at D:/Android/Sdk
    • Emulator version 34.1.19.0 (build_id 11525734) (CL:N/A)
    X cmdline-tools component is missing.
      Try installing or updating Android Studio.
      Alternatively, download the tools from https://developer.android.com/studio#command-line-tools-only and make sure
      to set the ANDROID_HOME environment variable.
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/windows-android-setup for more details.

[√] Chrome - develop for the web [361ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.31) [360ms]
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.11.34114.132
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2024.1) [8ms]
    • Android Studio at D:\Program Files\Android\Android Studio2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)

[√] IntelliJ IDEA Ultimate Edition (version 2024.2) [7ms]
    • IntelliJ at D:\Program Files\JetBrains\IntelliJ IDEA 2024.2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] Connected device (3 available) [235ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22631.5624]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 139.0.7258.128
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 139.0.3405.102

[√] Network resources [433ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions