import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';

class AppExpandableNotifier extends StatelessWidget {
  final Widget headerWid;
  final Widget bodyWid;

  AppExpandableNotifier({this.headerWid, this.bodyWid});

  @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: headerWid,
              ),
              ScrollOnExpand(
                scrollOnExpand: true,
                scrollOnCollapse: false,
                child: ExpandablePanel(
                  theme: const ExpandableThemeData(
                    headerAlignment: ExpandablePanelHeaderAlignment.center,
                    tapBodyToCollapse: true,
                  ),
                  header: Padding(
                      padding: EdgeInsets.all(10),
                      child: Text(
                        "See Graph Details",
                        style: TextStyle(fontWeight: FontWeight.bold),
                      )),
                  collapsed: Text(''),
                  expanded: bodyWid,
                  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),
                      ),
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      ),
      initialExpanded: true,
    );
  }
}
