基础组件库
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

60 righe
1.9 KiB

  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:zhiying_base_widget/widgets/public/custom_button/custom_button_model.dart';
  4. import 'package:zhiying_comm/zhiying_comm.dart';
  5. class CustomButton extends StatelessWidget {
  6. final CustomButtonModel style;
  7. final VoidCallback onClick;
  8. const CustomButton(this.style, {Key key, this.onClick}) : super(key: key);
  9. @override
  10. Widget build(BuildContext context) {
  11. var decoration = BoxDecoration(
  12. color: HexColor.fromHex(style.bgColor ?? ''),
  13. borderRadius: BorderRadius.circular(50));
  14. if (style.bgType == 'image') {
  15. decoration = BoxDecoration(
  16. image: DecorationImage(
  17. image: CachedNetworkImageProvider(style.bgImage ?? ''),
  18. fit: BoxFit.cover),
  19. borderRadius: BorderRadius.circular(50));
  20. }
  21. return GestureDetector(
  22. child: Container(
  23. width: double.infinity,
  24. height: double.infinity,
  25. decoration: decoration,
  26. child: Center(
  27. child: Row(
  28. crossAxisAlignment: CrossAxisAlignment.center,
  29. mainAxisAlignment: MainAxisAlignment.center,
  30. children: <Widget>[
  31. style.smallIcon == null || style.smallIcon == ''
  32. ? Container()
  33. : Container(
  34. width: 14,
  35. height: 14,
  36. margin: EdgeInsets.only(right: 4),
  37. child: CachedNetworkImage(
  38. imageUrl: style.smallIcon,
  39. fit: BoxFit.cover,
  40. ),
  41. ),
  42. Text(
  43. style.name,
  44. style: TextStyle(
  45. color: HexColor.fromHex(style.textColor ?? ''),
  46. fontSize: 14,
  47. ),
  48. )
  49. ],
  50. ),
  51. ),
  52. ),
  53. onTap: onClick,
  54. );
  55. }
  56. }