Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.3.0
* Update
- `ExpansionTileGroup` with new parameters `keepState`.
- Avoid column main axis use all available space. Thanks for [#53](https://github.com/congthanhng/Expansion-Tile-Group/pull/53)

## 2.2.0
* New Feature:
- Only trailing can toggle the state: `isOnlyTrailingDoToggle` [#42](https://github.com/congthanhng/Expansion-Tile-Group/pull/42)
Expand Down
15 changes: 8 additions & 7 deletions doc/group-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ class ExpansionGroupExample extends StatelessWidget {
That's it!

### ExpansionTileGroup parameters
| Parameter | Description |
|--------------------------|--------------------------------------------------------------|
| `key` | Controls how one widget replaces another widget in the tree. |
| `children`* | The children in this group, `ExpansionTileItem` |
| `toggleType` | Provide the behaviors of items in this group, it's `enum` |
| `spaceBetweenItem` | The gap space between item in the group |
| `onExpansionItemChanged` | Listen the changed behavior of any item in the group |
| Parameter | Description |
|--------------------------|----------------------------------------------------------------------------------------|
| `key` | Controls how one widget replaces another widget in the tree. |
| `children`* | The children in this group, `ExpansionTileItem` |
| `toggleType` | Provide the behaviors of items in this group, it's `enum` |
| `spaceBetweenItem` | The gap space between item in the group |
| `keepState` | Will keep the state of the expansion tile whenever the parent's node widget is rebuilt |
| `onExpansionItemChanged` | Listen the changed behavior of any item in the group |

## Let implement with Option 2: Using `ExansionGroupController`
Why do we have option 2 while option 1 work well?
Expand Down
1 change: 1 addition & 0 deletions doc/item-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ Now you can change default trailing icon by calling `trailingIcon`, it is retrie
| `isEnableExpanded` | Force item expand or NOT |
| `isDefaultVerticalPadding` | Remove completely default vertical title padding |
| `isHideSubtitleOnExpanded` | Hide Subtitle when view is expanded |
| `isOnlyTrailingDoToggle` | Only trailing can toggle the state [#42](https://github.com/congthanhng/Expansion-Tile-Group/pull/42) |
| `trailingIcon` | Change default trailing icon with keeping rotate animation |

## Additional ExpansionTileLeaf parameters
Expand Down
6 changes: 5 additions & 1 deletion example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# example

A new Flutter project.
An example Flutter project to demonstrate the `expansion_tile_group` package.

## Getting Started

Expand All @@ -25,3 +25,7 @@ dart pub global activate dhttpd
dart pub global run dhttpd --path doc/api
```
## Build demo web
flutter build web --release

## Public package
dart pub publish --dry-run
10 changes: 10 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:expansion_tile_group_example/route_named.dart';
import 'package:expansion_tile_group_example/use_cases/fantasy/fantasy_page.dart';
import 'package:expansion_tile_group_example/use_cases/group/custom_group_with_controller.dart';
import 'package:expansion_tile_group_example/use_cases/group/keep_state_page.dart';
import 'package:flutter/material.dart';

import 'use_cases/use_cases.dart';
Expand Down Expand Up @@ -55,6 +56,9 @@ class _MyAppState extends State<MyApp> {
builder: (context) => const CustomGroupWithController());
case RouteNamed.fantasyPage:
return MaterialPageRoute(builder: (context) => const FantasyPage());
case RouteNamed.keepStatePage:
return MaterialPageRoute(
builder: (context) => const KeepStatePage());
default:
return MaterialPageRoute(builder: (context) => const HomePage());
}
Expand Down Expand Up @@ -166,6 +170,12 @@ class HomePage extends StatelessWidget {
routeName: RouteNamed.listenGroupItemChanged,
),
const Divider(),
_buildRow(
context,
title: 'Keep state Example',
routeName: RouteNamed.keepStatePage,
),
const Divider(),
const Text(
'CUSTOM GROUP',
style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold),
Expand Down
1 change: 1 addition & 0 deletions example/lib/route_named.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ class RouteNamed {
static const String ignoreBehavior = '/ignore_behavior';
static const String hideSubtitle = '/hide_subtitle';
static const String fantasyPage = '/fantasy_page';
static const String keepStatePage = '/keep_state_page';
}
118 changes: 118 additions & 0 deletions example/lib/use_cases/group/keep_state_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import 'package:expansion_tile_group/expansion_tile_group.dart';
import 'package:flutter/material.dart';

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

@override
State<KeepStatePage> createState() => _KeepStatePageState();
}

class _KeepStatePageState extends State<KeepStatePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Keep State Example'),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Row(
children: [
_buildGroupLayout(
context,
title: 'Group 1: keepState: true',
child: ExpansionTileGroup(
spaceBetweenItem: 16,
keepState: true,
children: [
_buildExpansionItem(context),
_buildExpansionItem(context),
_buildExpansionItem(context),
],
),
),
const SizedBox(
width: 16,
),
_buildGroupLayout(
context,
title: 'Group 2: keepState: false',
child: ExpansionTileGroup(
spaceBetweenItem: 16,
keepState: false,
children: [
_buildExpansionItem(context),
_buildExpansionItem(context),
_buildExpansionItem(context),
],
),
),
],
),
const SizedBox(
height: 16,
),
const Text(
'Try to expand some items of each group and then tap to below button, you can see the different',
textAlign: TextAlign.center,
),
const SizedBox(
height: 16,
),
ElevatedButton(
onPressed: () {
setState(() {});
},
child: const Text('Rebuild this Page')),
],
),
),
),
);
}

ExpansionTileItem _buildExpansionItem(BuildContext context,
{bool isExpanded = false}) {
return ExpansionTileItem.outlined(
initiallyExpanded: isExpanded,
title: const Text('ExpansionTile Item'),
children: [
Material(
child: InkWell(
onTap: () {},
child: const Text(
''' Nullam eleifend ultrices tortor, sit amet gravida sapien cursus vitae. Duis rutrum convallis erat et ultrices. Morbi a luctus ligula, at varius ligula. Nam mollis sapien ac nunc hendrerit consequat. Cras posuere metus felis, at pellentesque sem ornare id. Praesent ut nunc aliquam, dictum felis eu, congue metus. Nunc vitae elit eros. In eu dui pharetra, varius metus a, efficitur eros.'''),
),
),
],
);
}

Widget _buildGroupLayout(BuildContext context,
{required String title, required Widget child}) {
return Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(fontSize: 20),
),
const SizedBox(
height: 16,
),
Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: child,
),
),
],
),
);
}
}
Loading