Skip to content

Conversation

@TahaTesser
Copy link
Member

This PR introduces AnimationStyle, it is used to override default animation curves and durations in several widgets.

fixes Add the ability to customize MaterialApp theme animation duration
fixes Allow customization of showMenu transition animation curves and duration
fixes AnimationStyle.noAnimation needs to replace AnimatedTheme with just Theme in the MaterialApp

Here is an example where popup menu curve and transition duration is overridden:

          popUpAnimationStyle: AnimationStyle(
            curve: Easing.emphasizedAccelerate,
            duration: Durations.medium4,
          ),

Set AnimationStyle.noAnimation to disable animation.

    return MaterialApp(
      themeAnimationStyle: AnimationStyle.noAnimation,

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. a: animation Animation APIs f: material design flutter/packages/flutter/material repository. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Nov 20, 2023
@TahaTesser TahaTesser marked this pull request as ready for review November 20, 2023 14:37
@HansMuller
Copy link
Contributor

Created (internal Google link) cl/584079753 to enable landing this change.

@HansMuller HansMuller added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 20, 2023
Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HansMuller HansMuller merged commit fc917c7 into flutter:master Nov 20, 2023
@TahaTesser TahaTesser deleted the reland-animationStyle branch November 21, 2023 08:36
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 21, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 21, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 21, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 21, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 21, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 21, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 21, 2023
Manual roll requested by [email protected]

flutter/flutter@9c9e061...ab721f9

2023-11-21 [email protected] Roll Flutter Engine from 6da31e1bff67 to 746697c27569 (1 revision) (flutter/flutter#138826)
2023-11-21 [email protected] Add mhbdev to AUTHORS (flutter/flutter#138311)
2023-11-21 [email protected] Manual roll Flutter Engine from 70b1c7341255 to 6da31e1bff67 (10 revisions) (flutter/flutter#138817)
2023-11-21 [email protected] Fix Chips with Tooltip throw an assertion when enabling or disabling (flutter/flutter#138799)
2023-11-21 [email protected] Roll Packages from c5443ad to c9933fc (2 revisions) (flutter/flutter#138809)
2023-11-21 [email protected] Roll Flutter Engine from 3348fb0ca302 to 70b1c7341255 (1 revision) (flutter/flutter#138774)
2023-11-21 [email protected] Roll Flutter Engine from f3e9b38a2588 to 3348fb0ca302 (1 revision) (flutter/flutter#138772)
2023-11-21 [email protected] Roll Flutter Engine from 39fb4581cff2 to f3e9b38a2588 (3 revisions) (flutter/flutter#138770)
2023-11-21 [email protected] Add dartdoc warnings (flutter/flutter#138766)
2023-11-21 [email protected] Roll Flutter Engine from 6e8e55ef1a7f to 39fb4581cff2 (2 revisions) (flutter/flutter#138765)
2023-11-20 [email protected] Added Features requested in #137530 (flutter/flutter#137532)
2023-11-20 [email protected] Bump dartdoc to 7.0.2 (flutter/flutter#138760)
2023-11-20 [email protected] Roll Flutter Engine from 7a31543b4630 to 6e8e55ef1a7f (4 revisions) (flutter/flutter#138761)
2023-11-20 [email protected] [Reland] Introduce `AnimationStyle` (flutter/flutter#138721)
2023-11-20 [email protected] Roll Flutter Engine from 337ab58e81f7 to 7a31543b4630 (2 revisions) (flutter/flutter#138759)
2023-11-20 [email protected] Reland update bottom navigation bar test for m3 (flutter/flutter#137998)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit bot pushed a commit that referenced this pull request Dec 6, 2023
fixes [Expose animation parameters for the [ExpansionTile] widget](#138047)

### Description
Add `AnimationStyle` to the `ExpansionTile` widget to override the default expand and close animation.

Syntax:
```dart
        child: ExpansionTile(
          title: const Text('Tap to expand'),
          expansionAnimationStyle: AnimationStyle(
            duration: Durations.extralong1,
            curve: Easing.emphasizedAccelerate,
          ),
          children: const <Widget>[FlutterLogo(size: 200)],
        ),
```

### Code sample

<details>
<summary>expand to view the code sample</summary> 

```dart
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

/// Flutter code sample for [ExpansionTile] and [AnimationStyle].

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

enum AnimationStyles { defaultStyle, custom, none }
const List<(AnimationStyles, String)> animationStyleSegments = <(AnimationStyles, String)>[
  (AnimationStyles.defaultStyle, 'Default'),
  (AnimationStyles.custom, 'Custom'),
  (AnimationStyles.none, 'None'),
];

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

  @OverRide
  State<ExpansionTileAnimationStyleApp> createState() => _ExpansionTileAnimationStyleAppState();
}

class _ExpansionTileAnimationStyleAppState extends State<ExpansionTileAnimationStyleApp> {
  Set<AnimationStyles> _animationStyleSelection = <AnimationStyles>{AnimationStyles.defaultStyle};
  AnimationStyle? _animationStyle;

  @OverRide
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              SegmentedButton<AnimationStyles>(
                selected: _animationStyleSelection,
                onSelectionChanged: (Set<AnimationStyles> styles) {
                  setState(() {
                    _animationStyleSelection = styles;
                    switch (styles.first) {
                      case AnimationStyles.defaultStyle:
                        _animationStyle = null;
                      case AnimationStyles.custom:
                        _animationStyle = AnimationStyle(
                          curve: Easing.emphasizedAccelerate,
                          duration: Durations.extralong1,
                        );
                      case AnimationStyles.none:
                        _animationStyle = AnimationStyle.noAnimation;
                    }
                  });
                },
                segments: animationStyleSegments
                  .map<ButtonSegment<AnimationStyles>>(((AnimationStyles, String) shirt) {
                    return ButtonSegment<AnimationStyles>(value: shirt.$1, label: Text(shirt.$2));
                  })
                  .toList(),
              ),
              const SizedBox(height: 20),
              ExpansionTile(
                expansionAnimationStyle: _animationStyle,
                title: const Text('ExpansionTile'),
                children: const <Widget>[
                  ListTile(title: Text('Expanded Item 1')),
                  ListTile(title: Text('Expanded Item 2')),
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}
```

</details>

Related to #138721.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: animation Animation APIs autosubmit Merge PR when tree becomes green via auto submit App d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

2 participants