Skip to content

AnimatedOpacity moves the child widget while playing the animation #83050

@krll-kov

Description

@krll-kov

h6qYbCHHSj

Maybe the problem happens because of the padding widget on top of the container. But if i remove Padding widget and add the padding attribute to a container, the issue disappears. However, sometimes, this issue occurs even without a padding widget(for example you can wrap the DropdownButtonFormField's icon inside of such AnimatedOpacity widget and also repeat the issue). alwaysIncludeSemantics attribute of the AnimatedOpacity widget does not make any difference.

As for adding padding inside of the container widget instead of wrapping it with a Padding widget: the issue does not disappear if you remove width: 150.0 and leave container with limitless width. But in my other project, it works the other way around(if i add the boundaries, the issue appears, but if remove them, it disappears), so i have no idea why it happens.

Code to reproduce the issue:

minimal code sample
import 'dart:ui';

import 'package:flutter/material.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _showSomething = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Material App',
      home: Scaffold(
        backgroundColor: Colors.green,
        body: Center(
          child:
            Column(
              children: [
                GestureDetector(
                  onTap: () => setState(() => _showSomething = !_showSomething),
                  child: Container(
                    alignment: Alignment.center,
                    height: 40.0,
                    width: 150.0,
                    color: Colors.redAccent,
                    child: Text(
                      'I am a cool button!',
                      style: TextStyle(color: Colors.white),
                    ),
                  ),
                ),
                AnimatedOpacity(
                  opacity: _showSomething ? 1.0 : 0.0,
                  duration: Duration(milliseconds: 425),
                  curve: Curves.easeInOutCubic,
                  alwaysIncludeSemantics: true,
                  child: Padding(
                    padding: EdgeInsets.only(top: 5.0, left: 5.0),
                    child: Container(
                      width: 150.0,
                      child: Text(
                        'Just a text for some reason with an unknown text to test the animation for exactly this text ',
                        style: TextStyle(color: Colors.white),
                      ),
                    ),
                  ),
                ),
              ],
            ),
        ),
      ),
    );
  }
}

Flutter version: The latest from the stable channel;

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: animationAnimation APIsfound in release: 2.2Found to occur in 2.2found in release: 2.3Found to occur in 2.3frameworkflutter/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