Skip to content

AccessibilityFeatures.disableAnimations flag is not set on app startup and animations are not disabled in app running on Android 12+ device. #130976

@sanderpensa

Description

@sanderpensa

Is there an existing issue for this?

Steps to reproduce

  1. On Android 12+ device disable animations from Settings > Accessibility > Remove animations.
  2. Run the app flutter run --release (does not matter if in release, profile or debug mode, we have this bug in live app also).
  3. Observe AccessibilityFeatures.disableAnimations flag is not set, animations are not removed.
  4. Put the app to backgound (do not close it), and change the "Remove animations" setting off and on again from Settings > Accessibility > Remove animations.
  5. Open app from recents, observe AccessibilityFeatures.disableAnimations flag is updated and set after few seconds and animations are disabled.

Expected results

App animations are disabled on Android 12+.

Actual results

Animations are not disabled.

Code sample

Code sample
import 'dart:ui';

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(
      title: 'Accessibility disableAnimations example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const SlideAnimationDemo(),
    );
  }
}

class SlideAnimationDemo extends StatefulWidget {
  const SlideAnimationDemo({super.key});

  @override
  State<SlideAnimationDemo> createState() => _SlideAnimationDemoState();
}

class _SlideAnimationDemoState extends State<SlideAnimationDemo>
    with SingleTickerProviderStateMixin, WidgetsBindingObserver {
  late AnimationController _animationController;
  late Animation<Offset> _slideAnimation;
  String features = '';

  @override
  void initState() {
    super.initState();

    WidgetsBinding.instance.addObserver(this);

    _animationController = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 1000),
    );

    _slideAnimation = Tween<Offset>(
      begin: const Offset(-1.0, 0.0),
      end: Offset.zero,
    ).animate(CurvedAnimation(
      parent: _animationController,
      curve: Curves.easeInOut,
    ));

    features = PlatformDispatcher.instance.accessibilityFeatures.toString();
  }

  @override
  void dispose() {
    _animationController.dispose();
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  void _playAnimation() {
    if (_animationController.status == AnimationStatus.completed) {
      _animationController.reverse();
    } else {
      _animationController.forward();
    }
  }

  @override
  void didChangeAccessibilityFeatures() {
    final newFeatures =
        PlatformDispatcher.instance.accessibilityFeatures.toString();
    debugPrint("didChangeAccessibilityFeatures $newFeatures");
    setState(() {
      features = newFeatures;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Slide animation demo'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const SizedBox(height: 20),
            Text(features),
            const SizedBox(height: 20),
            SlideTransition(
              position: _slideAnimation,
              child: Container(
                width: 100,
                height: 100,
                color: Colors.red,
              ),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: _playAnimation,
              child: const Text('Animate'),
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.19044.3086], locale et-EE)
    • Flutter version 3.10.6 on channel stable at C:\Users\sande\fvm\versions\3.10.6
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (8 days ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

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

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\sande\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.2
    • ANDROID_HOME = C:\Users\sande\AppData\Local\Android\sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java      
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

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

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.3)   
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community  
    • Visual Studio Community 2022 version 17.2.32526.322
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.6+0-b2043.56-9586694)

[√] IntelliJ IDEA Community Edition (version 2019.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.1
    • 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

[√] IntelliJ IDEA Community Edition (version 2022.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.1.1
    • 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

[√] VS Code, 64-bit edition (version 1.80.0)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.68.0

[√] Connected device (4 available)
    • Pixel 3 XL (mobile) • 8ABY0HG2L • android-arm64  • Android 12 (API 31)
    • Windows (desktop)   • windows   • windows-x64    • Microsoft Windows [Version 10.0.19044.3086]
    • Chrome (web)        • chrome    • web-javascript • Google Chrome 114.0.5735.199
    • Edge (web)          • edge      • web-javascript • Microsoft Edge 114.0.1823.55

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

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)e: OS-version specificAffects only some versions of the relevant operating systemengineflutter/engine related. See also e: labels.found in release: 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions