Skip to content

liveRegion not working as expected on Android #45930

Closed
flutter-team-archive/engine
#14081

Description

@dnfield

I would expect the following program to make polite announcements when the counter updates, but it doesn't.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

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

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('You have pushed the button this many times:'),
            Semantics(
              liveRegion: true,
              child: Text(
                '$_counter',
                style: Theme.of(context).textTheme.display1,
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

/cc @goderbauer @jonahwilliams who may have insight

/cc @darrenaustin

Activity

  1. added
    platform-androidAndroid applications specifically
    frameworkflutter/packages/flutter repository. See also f: labels.
    engineflutter/engine related. See also e: labels.
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    on Dec 2, 2019
  2. dnfield commented on Dec 2, 2019

    @dnfield
    ContributorAuthor

    This might be a user error. The following does seem to work as expected:

    MaterialApp(
            home: MediaQuery(
                data: const MediaQueryData(accessibleNavigation: true),
                child: Scaffold(
                    key: scaffoldKey,
                    body: Builder(
                      builder: (BuildContext context) {
                        return GestureDetector(
                            onTap: () {
                              Scaffold.of(context).showSnackBar(SnackBar(
                                content: const Text('snack'),
                                duration: const Duration(seconds: 1),
                                action: SnackBarAction(
                                    label: 'ACTION',
                                    onPressed: () { },
                                ),
                              ));
                            },
                            child: const Text('X'),
                        );
                      },
                    ),
                ),
            ),
        )
  3. dnfield commented on Dec 2, 2019

    @dnfield
    ContributorAuthor

    If I set liveRegion: _counter > 1 and then increment a few times, it announces 2 when I hit 2 but then doesn't announce again.

  4. dnfield commented on Dec 2, 2019

    @dnfield
    ContributorAuthor

    Another find: https://github.com/flutter/engine/blob/master/shell/platform/android/io/flutter/view/AccessibilityBridge.java#L228 doesn't seem to implement handling for the UpdateLiveRegionAnnouncement, so sending that is basically a no-op.

  5. github-actions commented on Aug 25, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)engineflutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.platform-androidAndroid applications specifically

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions