Flutter Accessibility issue with Google Play and Accessibility Scanner

Viewed 22

I'm trying to upload an application coded with flutter and i receive the same issue about content labeling.

This is the message i receiv when running Accessibility Scanner app. The same accesibility issue is returnet by Google Play.

enter image description here

I've tried to add semantics everywhere without success. Also i tried using WidgetsFlutterBinding.ensureInitialized(); and RendererBinding.instance.setSemanticsEnabled(true); both or separated, but always the same.

Which is the right way to set semantics to pass Google Play or Accessibility Scanner?

My code:

import 'package:flutter/material.dart';
import 'package:gitrepotest/colors.dart';
import 'app_style.dart';
import 'styles.dart';

void main() {
  runApp(
    Semantics(
      label: "Label 1",
      focusable: false,
      enabled: false,
      child: const MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  void logReg() {
    // ignore: avoid_print
    print("Time ${DateTime.now().millisecondsSinceEpoch}");
  }

  @override
  Widget build(BuildContext context) {
    return Semantics(
      label: "Label 2",
      child: MaterialApp(
        debugShowCheckedModeBanner: false,
        showSemanticsDebugger: false,
        title: 'Flutter Demo',
        theme: AppStyle.appTheme,
        home: Semantics(
          label: "Label 3",
          child: SafeArea(
            child: Semantics(
              label: "Label 4",
              child: Scaffold(
                backgroundColor: Clr.pageBackground2,
                appBar: AppBar(
                  title: Semantics(
                    child: const Text(
                      "Semantics demo",
                      semanticsLabel: "Demo",
                    ),
                  ),
                ),
                body: Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Semantics(
                        excludeSemantics: true,
                        child: Text(
                          "Time ${DateTime.now().millisecondsSinceEpoch}",
                          style: Sty.textN(Clr.blackSoft, 3),
                        ),
                      ),
                      Semantics(
                        container: true,
                        child: OutlinedButton(
                          style: ButtonStyle(
                            padding: MaterialStateProperty.all(const EdgeInsets.only(left: 30, right: 30)),
                            backgroundColor: MaterialStateProperty.all(Clr.green),
                            shape: MaterialStateProperty.all(
                              RoundedRectangleBorder(
                                borderRadius: BorderRadius.circular(15),
                              ),
                            ),
                          ),
                          onPressed: logReg,
                          child: Text(
                            "Click",
                            style: Sty.textB(Clr.black, 2),
                            semanticsLabel: "Log registration",
                          ),
                        ),
                      )
                    ],
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

0 Answers
Related