Hibok
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

59 satır
1.6 KiB

  1. import 'package:chat/data/constants.dart';
  2. import 'package:chat/generated/i18n.dart';
  3. import 'package:flutter/material.dart';
  4. class UserChips extends StatelessWidget {
  5. final String city; //城市
  6. final int age; //年龄
  7. final String constellation; //星座
  8. final String professional; //职业
  9. final Color bgColor;
  10. final TextStyle fontStyle;
  11. final bool isCenter;
  12. const UserChips(
  13. {Key key,
  14. this.city,
  15. this.age,
  16. this.constellation,
  17. this.professional,
  18. this.bgColor,
  19. this.fontStyle,
  20. this.isCenter: false})
  21. : super(key: key);
  22. Widget _buildChip(str) {
  23. return Container(
  24. margin: EdgeInsets.only(bottom: 5, right: 5),
  25. padding: EdgeInsets.symmetric(horizontal: 10, vertical: 3),
  26. decoration: BoxDecoration(
  27. color: bgColor == null ? Constants.LightBlueBackgroundColor : bgColor,
  28. borderRadius: BorderRadius.circular(15.0),
  29. ),
  30. child: Text(
  31. str,
  32. textScaleFactor: 1.0,
  33. style: fontStyle == null
  34. ? TextStyle(
  35. fontSize: 11,
  36. color: Constants.LightBlueTextColor,
  37. )
  38. : fontStyle,
  39. textAlign: TextAlign.center,
  40. ),
  41. );
  42. }
  43. @override
  44. Widget build(BuildContext context) {
  45. return Wrap(
  46. alignment: isCenter ? WrapAlignment.center : WrapAlignment.start,
  47. crossAxisAlignment: WrapCrossAlignment.center,
  48. children: <Widget>[
  49. _buildChip(city),
  50. _buildChip(professional),
  51. _buildChip('$age ${I18n.of(context).years_old}-$constellation'),
  52. ],
  53. );
  54. }
  55. }