Hibok
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

111 lignes
3.1 KiB

  1. import 'package:flutter/material.dart';
  2. import '../data/constants.dart' show Constants, AppColors;
  3. class FullWidthButton extends StatelessWidget {
  4. static const Hor_Padding = 5.0;
  5. static const Ver_Padding = 10.0;
  6. final String title;
  7. final bool showDivider;
  8. final VoidCallback onPressed;
  9. final String description;
  10. final Color descriptionColor;
  11. final bool showRightIcon;
  12. final int iconCode;
  13. final iconColor;
  14. final Widget extendWidget;
  15. const FullWidthButton(
  16. {@required this.title,
  17. this.description = '',
  18. @required this.onPressed,
  19. this.descriptionColor,
  20. this.showRightIcon: true,
  21. this.showDivider: false,
  22. this.iconCode,
  23. this.iconColor,
  24. this.extendWidget})
  25. : assert(title != null),
  26. assert(onPressed != null);
  27. @override
  28. Widget build(BuildContext context) {
  29. final pureButton = Row(
  30. mainAxisAlignment: MainAxisAlignment.start,
  31. crossAxisAlignment: CrossAxisAlignment.center,
  32. children: <Widget>[
  33. iconCode == null
  34. ? Container()
  35. : Container(
  36. //color: Colors.red,
  37. margin: EdgeInsets.only(right: 5, bottom: 3, top: 1.5),
  38. child: Icon(
  39. IconData(
  40. iconCode,
  41. fontFamily: 'iconfont',
  42. ),
  43. color: Color(iconColor),
  44. size: 20,
  45. )),
  46. SizedBox(width: Hor_Padding),
  47. Expanded(
  48. child: Text(
  49. title,
  50. textScaleFactor: 1.0,
  51. style: TextStyle(fontSize: 14, fontWeight: FontWeight.normal),
  52. ),
  53. ),
  54. extendWidget != null
  55. ? extendWidget
  56. : Text(
  57. description,
  58. textScaleFactor: 1.0,
  59. textAlign: TextAlign.end,
  60. style: TextStyle(
  61. fontSize: 12,
  62. fontWeight: FontWeight.normal,
  63. color: descriptionColor == null
  64. ? const Color(0xFF818181)
  65. : descriptionColor),
  66. ),
  67. showRightIcon
  68. ? Padding(
  69. padding: EdgeInsets.only(bottom: 1.5),
  70. child: Icon(
  71. IconData(0xe63c, fontFamily: 'iconfont'),
  72. size: 20.0,
  73. color: Color(AppColors.TabIconNormal),
  74. ))
  75. : Padding(padding: EdgeInsets.only(right: 7)),
  76. ],
  77. );
  78. final borderButton = Container(
  79. decoration: BoxDecoration(
  80. border: Border(
  81. bottom: Constants.GreyBorderSide,
  82. ),
  83. ),
  84. padding: EdgeInsets.only(
  85. bottom: Ver_Padding,
  86. ),
  87. child: pureButton,
  88. );
  89. return FlatButton(
  90. onPressed: () {
  91. this.onPressed();
  92. },
  93. padding: EdgeInsets.only(
  94. left: Hor_Padding,
  95. right: Hor_Padding,
  96. top: Ver_Padding,
  97. bottom: showDivider ? 0.0 : Ver_Padding,
  98. ),
  99. color: Colors.white,
  100. child: showDivider ? borderButton : pureButton,
  101. );
  102. }
  103. }