You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.1 KiB
Dart
66 lines
2.1 KiB
Dart
4 years ago
|
import 'package:expandable/expandable.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
/// App Expandable Notifier with animation
|
||
|
/// [headerWidget] widget want to show in the header
|
||
|
/// [bodyWidget] widget want to show in the body
|
||
|
/// [title] the widget title
|
||
|
/// [collapsed] The widget shown in the collapsed state
|
||
|
class AppExpandableNotifier extends StatelessWidget {
|
||
|
final Widget headerWidget;
|
||
|
final Widget bodyWidget;
|
||
|
final String title;
|
||
|
final Widget collapsed;
|
||
|
|
||
|
AppExpandableNotifier(
|
||
|
{this.headerWidget, this.bodyWidget, this.title, this.collapsed});
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return ExpandableNotifier(
|
||
|
child: Padding(
|
||
|
padding: const EdgeInsets.all(10),
|
||
|
child: Card(
|
||
|
clipBehavior: Clip.antiAlias,
|
||
|
child: Column(
|
||
|
children: <Widget>[
|
||
|
SizedBox(
|
||
|
child: headerWidget,
|
||
|
),
|
||
|
ScrollOnExpand(
|
||
|
scrollOnExpand: true,
|
||
|
scrollOnCollapse: false,
|
||
|
child: ExpandablePanel(
|
||
|
theme: const ExpandableThemeData(
|
||
|
headerAlignment: ExpandablePanelHeaderAlignment.center,
|
||
|
tapBodyToCollapse: true,
|
||
|
),
|
||
|
header: Padding(
|
||
|
padding: EdgeInsets.all(10),
|
||
|
child: Text(
|
||
|
title,
|
||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||
|
),
|
||
|
),
|
||
|
collapsed: collapsed,
|
||
|
expanded: bodyWidget,
|
||
|
builder: (_, collapsed, expanded) {
|
||
|
return Padding(
|
||
|
padding: EdgeInsets.only(left: 10, right: 10, bottom: 10),
|
||
|
child: Expandable(
|
||
|
collapsed: collapsed,
|
||
|
expanded: expanded,
|
||
|
theme: const ExpandableThemeData(crossFadePoint: 0),
|
||
|
),
|
||
|
);
|
||
|
},
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|