Skip to content

[Material3] IconButton's isSelected not visible to screen readers #127145

@chrisbobbe

Description

@chrisbobbe

Is there an existing issue for this?

Steps to reproduce

  1. Run my sample, pasted below.
  2. Tap the button in the center a few times. It has two states: selected and unselected.
  3. Activate a screen reader (I used VoiceOver on iOS)
  4. Use the screen reader to cause the button to be "pressed". (With VoiceOver, I found this is done with a double-tap.)
  5. Notice that its tooltip ("hello") is read, but the selected/unselected state is not.

Expected results

I expected the selected/unselected state to be read aloud.

Actual results

The selected/unselected state was not read aloud.

Code sample

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: Theme.of(context).copyWith(useMaterial3: true),
      home: const Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Button:'),
              MyButton(),
            ],
          ),
        ),
      ),
    );
  }
}

class MyButton extends StatefulWidget {
  const MyButton({Key? key}) : super(key: key);

  @override
  State<MyButton> createState() => _MyButtonState();
}

class _MyButtonState extends State<MyButton> {
  bool _selected = false;

  @override
  Widget build(BuildContext context) {
    return IconButton(
      onPressed: () {
        setState(() {
          _selected = !_selected;
        });
      },
      tooltip: 'hello',
      isSelected: _selected,
      icon: const Icon(Icons.arrow_left),
      selectedIcon: const Icon(Icons.arrow_right),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

N/A

Logs

Logs

No errors logged or expected.

Flutter Doctor output

Doctor output
$ flutter doctor -v
[✓] Flutter (Channel main, 3.11.0-6.0.pre.35, on macOS 13.3.1 22E772610a darwin-x64, locale en-US)
    • Flutter version 3.11.0-6.0.pre.35 on channel main at /Users/chrisbobbe/.local/lib/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 37fe1e9d77 (7 days ago), 2023-05-11 12:43:40 -0400
    • Engine revision f38f46f66e
    • Dart version 3.1.0 (build 3.1.0-94.0.dev)
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/chrisbobbe/Library/Android/sdk
    • Platform android-33, build-tools 30.0.3
    • ANDROID_HOME = /Users/chrisbobbe/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • Chris’s iPhone (mobile) • 00008110-000924383632801E • ios            • iOS 16.4.1 20E252
    • macOS (desktop)         • macos                     • darwin-x64     • macOS 13.3.1 22E772610a darwin-x64
    • Chrome (web)            • chrome                    • web-javascript • Google Chrome 113.0.5672.126
    ! Error: Chris’s Apple Watch needs to connect to determine its availability. Check the connection between the
      device and its companion iPhone, and the connection between the iPhone and Xcode. Both devices may also need to
      be restarted and unlocked. (code 1)

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)f: material designflutter/packages/flutter/material repository.found in release: 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions