| 1 | import 'package:flutter/material.dart'; |
| 2 | |
| 3 | class ListRow extends StatelessWidget { |
| 4 | ListRow( |
| 5 | {required this.title, |
| 6 | required this.value, |
| 7 | this.titleFontSize = 14, |
| 8 | this.valueFontSize = 16, |
| 9 | this.image, |
| 10 | this.padding, |
| 11 | this.color, |
| 12 | this.hintTextColor, |
| 13 | this.mainTextColor, |
| 14 | this.textWidget}); |
| 15 | |
| 16 | final String title; |
| 17 | final String value; |
| 18 | final double titleFontSize; |
| 19 | final double valueFontSize; |
| 20 | final Widget? image; |
| 21 | final EdgeInsetsGeometry? padding; |
| 22 | final Color? color; |
| 23 | final Color? hintTextColor; |
| 24 | final Color? mainTextColor; |
| 25 | final Widget? textWidget; |
| 26 | |
| 27 | Widget _getTextWidget(BuildContext context) => |
| 28 | textWidget ?? |
| 29 | Text( |
| 30 | value, |
| 31 | style: Theme.of(context).textTheme.bodyMedium?.copyWith( |
| 32 | fontSize: valueFontSize, |
| 33 | fontWeight: FontWeight.w500, |
| 34 | color: mainTextColor, |
| 35 | ), |
| 36 | ); |
| 37 | |
| 38 | @override |
| 39 | Widget build(BuildContext context) { |
| 40 | return Container( |
| 41 | width: double.infinity, |
| 42 | color: color ?? Theme.of(context).colorScheme.surface, |
| 43 | child: Padding( |
| 44 | padding: padding ?? const EdgeInsets.only(left: 24, top: 16, bottom: 16, right: 24), |
| 45 | child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ |
| 46 | Text( |
| 47 | title, |
| 48 | style: Theme.of(context).textTheme.bodyMedium?.copyWith( |
| 49 | fontSize: titleFontSize, |
| 50 | fontWeight: FontWeight.w500, |
| 51 | color: hintTextColor, |
| 52 | ), |
| 53 | textAlign: TextAlign.left, |
| 54 | ), |
| 55 | Padding( |
| 56 | padding: const EdgeInsets.only(top: 12), |
| 57 | child: Row( |
| 58 | mainAxisSize: MainAxisSize.max, |
| 59 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 60 | crossAxisAlignment: CrossAxisAlignment.start, |
| 61 | children: <Widget>[ |
| 62 | Expanded(child: _getTextWidget(context)), |
| 63 | image != null |
| 64 | ? Padding( |
| 65 | padding: EdgeInsets.only(left: 24), |
| 66 | child: image, |
| 67 | ) |
| 68 | : Offstage() |
| 69 | ], |
| 70 | ), |
| 71 | ) |
| 72 | ]), |
| 73 | ), |
| 74 | ); |
| 75 | } |
| 76 | } |