import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:test_sa/views/app_style/sizing.dart'; class ExpandableInfoRow extends StatefulWidget { final IconData iconData; final String title; final Widget child; const ExpandableInfoRow({Key key, this.iconData, this.title, this.child}) : super(key: key); @override _ExpandableInfoRowState createState() => _ExpandableInfoRowState(); } class _ExpandableInfoRowState extends State with TickerProviderStateMixin{ bool _isExpanded = false; @override Widget build(BuildContext context) { return InkWell( onTap: (){ _isExpanded = !_isExpanded; setState(() {}); }, child: Column( children: [ Row( children: [ widget.iconData != null ? Padding( padding: EdgeInsets.symmetric( horizontal: 8 * AppStyle.getScaleFactor(context), vertical: 2 * AppStyle.getScaleFactor(context), ), child: FaIcon( widget.iconData, color: Theme.of(context).primaryColor, size: 20 * AppStyle.getScaleFactor(context), ), ):SizedBox.shrink(), Expanded( flex: 2, child: Text( widget.title, style: TextStyle( //color: Theme.of(context).dividerColor, fontSize: 14, fontWeight: FontWeight.bold, ), textScaleFactor: AppStyle.getScaleFactor(context), ), ), AnimatedSwitcher( duration: Duration(milliseconds: 400), transitionBuilder: (Widget child, Animation animation) { return FadeTransition( child: ScaleTransition( child: child, scale: animation ), opacity: animation, ); }, child: Icon( _isExpanded ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, key: ValueKey(_isExpanded ? "Icons.keyboard_arrow_up" : "Icons.keyboard_arrow_down"), color: Theme.of(context).primaryColor, size: 24 * AppStyle.getScaleFactor(context), ), ), ], ), AnimatedSize( duration: Duration(milliseconds: 300), child: Visibility( visible: _isExpanded, child: Padding( padding: EdgeInsets.symmetric(vertical: 8 * AppStyle.getScaleFactor(context)), child: widget.child, ) ), ), Divider(height: 2 * AppStyle.getScaleFactor(context),), SizedBox(height: 8 * AppStyle.getScaleFactor(context),), ], ), ); } }