flutter/examples/api/lib/material
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
..
about Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
action_buttons Add missing links to examples that aren't linked anywhere (#130422) 2023-07-12 20:08:05 +00:00
action_chip Enable dangling_library_doc_comments and library_annotations lints (#117365) 2022-12-20 16:03:21 -08:00
animated_icon Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
app [Reland] Introduce AnimationStyle (#138721) 2023-11-20 15:24:41 -08:00
app_bar Replaces textScaleFactor with TextScaler (#128522) 2023-07-17 17:56:07 +00:00
autocomplete fix some typos (#137144) 2023-10-24 15:27:07 +00:00
banner Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
bottom_app_bar Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
bottom_navigation_bar Enable strict-inference (#135043) 2023-09-20 19:59:08 +00:00
bottom_sheet Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
button_style Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
card Add Card.filled and Card.outlined factory methods (#136229) 2023-11-01 23:29:49 +00:00
checkbox Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
checkbox_list_tile Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
chip Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
choice_chip Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
color_scheme Remove dead code (#126266) 2023-05-09 15:47:16 +00:00
context_menu Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
data_table Fix DataTable example not being scrollable (#131556) 2023-09-11 18:55:53 -05:00
date_picker Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
dialog Adaptive alert dialog (#124336) 2023-04-18 23:00:03 +00:00
divider Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
drawer Add missing example links (#130521) 2023-07-17 18:24:49 +00:00
dropdown Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
dropdown_menu Improve DropdownMenu sample code for requestFocusOnTap on mobile platforms (#134867) 2023-09-18 08:33:14 +00:00
elevated_button Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
expansion_panel Update ExpansionPanel example for the updated expansionCallback callback (#132837) 2023-08-21 20:13:22 +00:00
expansion_tile Add AnimationStyle to ExpansionTile (#139664) 2023-12-06 16:40:24 +00:00
filled_button Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
filter_chip Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
flexible_space_bar Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
floating_action_button Add FAB Additional Color Mappings example (#133453) 2023-08-29 17:31:02 +00:00
floating_action_button_location Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
icon_button Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
ink Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
ink_well Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
input_chip Add an example for InputChip generated by user input (#130645) 2023-09-01 00:02:04 +00:00
input_decorator Updated InputDecoratorExamples for M3 (#128065) 2023-06-01 15:22:03 -07:00
list_tile Fix typos in ListTile examples. (#129606) 2023-06-29 06:29:03 +00:00
material_state Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
menu_anchor Convert menus to use OverlayPortal (#130534) 2023-10-18 20:13:08 +00:00
navigation_bar Remove unused generic type from BottomSheet (#137791) 2023-11-03 22:25:37 +00:00
navigation_drawer Add missing example links (#130521) 2023-07-17 18:24:49 +00:00
navigation_rail Add Badge widget to NavigationBar and NavigationRail examples (#129834) 2023-07-11 09:30:05 +00:00
outlined_button Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
page_transitions_theme Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
paginated_data_table PaginatedDataTable improvements (#131374) 2023-08-15 00:55:07 +00:00
platform_menu_bar Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
popup_menu [Reland] Introduce AnimationStyle (#138721) 2023-11-20 15:24:41 -08:00
progress_indicator Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
radio Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
radio_list_tile Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
range_slider Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
refresh_indicator Refactor refresh_indicator.1.dart to not use shrinkwrap (#129377) 2023-07-11 20:04:17 +00:00
reorderable_list Add a ReorderableListView example with cards + cleanup existing tests (#126155) 2023-05-05 16:39:11 +00:00
scaffold Remove unused generic type from BottomSheet (#137791) 2023-11-03 22:25:37 +00:00
scrollbar fix a Scrollbar example crash (#127925) 2023-09-08 09:40:49 +00:00
search_anchor Add missing links to examples that aren't linked anywhere (#130422) 2023-07-12 20:08:05 +00:00
segmented_button Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
selectable_region Selection area right click behavior should match native (#128224) 2023-06-21 19:32:04 +00:00
selection_area Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
selection_container Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
slider Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
snack_bar Add missing links to examples that aren't linked anywhere (#130422) 2023-07-12 20:08:05 +00:00
stepper Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
switch Adaptive Switch (#130425) 2023-11-07 10:26:23 -08:00
switch_list_tile Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
tab_controller Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
tabs Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
text_button Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
text_field Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
text_form_field Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
theme Rename Sample classes (#124080) 2023-04-04 20:34:29 +00:00
theme_data Fix Typos (#137292) 2023-10-26 23:55:38 +00:00
time_picker Replaces textScaleFactor with TextScaler (#128522) 2023-07-17 17:56:07 +00:00
toggle_buttons Updated TabBar and ToggleButtons examples (#128088) 2023-06-02 01:05:31 +00:00
tooltip Tooltip docs: Recommend setting preferBelow to false in theme (#135879) 2023-11-03 20:18:36 +00:00