flutter/examples
Taha Tesser f794cf9d97
Add AnimationStyle to ExpansionTile (#139664)
fixes [Expose animation parameters for the [ExpansionTile] widget](https://github.com/flutter/flutter/issues/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 https://github.com/flutter/flutter/pull/138721.
2023-12-06 16:40:24 +00:00
..
api Add AnimationStyle to ExpansionTile (#139664) 2023-12-06 16:40:24 +00:00
flutter_view [flutter_tools] - Add queries section to Android manifest file (#137207) 2023-11-16 08:57:20 +00:00
hello_world [flutter_tools] - Add queries section to Android manifest file (#137207) 2023-11-16 08:57:20 +00:00
image_list [flutter_tools] - Add queries section to Android manifest file (#137207) 2023-11-16 08:57:20 +00:00
layers [flutter_tools] - Add queries section to Android manifest file (#137207) 2023-11-16 08:57:20 +00:00
platform_channel [flutter_tools] - Add queries section to Android manifest file (#137207) 2023-11-16 08:57:20 +00:00
platform_channel_swift Pin package:web 0.4.0 (#138428) 2023-11-15 15:03:21 -08:00
platform_view [flutter_tools] - Add queries section to Android manifest file (#137207) 2023-11-16 08:57:20 +00:00
splash Pin package:web 0.4.0 (#138428) 2023-11-15 15:03:21 -08:00
texture Pin package:web 0.4.0 (#138428) 2023-11-15 15:03:21 -08:00
.clang-format Implement Linux part of examples (#108068) 2022-12-08 08:44:11 +13:00
flutter_gallery.readme Move flutter_gallery to the testing folder (#52532) 2020-03-16 10:31:42 +01:00
README.md Fix typo in README.md (#126053) 2023-05-04 14:58:17 +02:00

Flutter Examples

This directory contains several examples of using Flutter. To run an example, use flutter run inside that example's directory. See the getting started guide to install the flutter tool.

For additional samples, see the flutter/samples repo.

Available examples include:

Notes

Note on Gradle wrapper files in .gitignore:

Gradle wrapper files should normally be checked into source control. The example projects don't do that to avoid having several copies of the wrapper binary in the Flutter repo. Instead, the Gradle wrapper is injected by Flutter tooling, and the wrapper files are .gitignore'd to avoid making the Flutter repository dirty as a side effect of running the examples.