import 'package:chat/generated/i18n.dart'; import 'package:flutter/material.dart'; class TempUserChips extends StatelessWidget { final String city; //城市 final int age; //年龄 final String constellation; //星座 final String professional; //职业 final Color bgColor; final TextStyle fontStyle; final bool isCenter; const TempUserChips( {Key key, this.city, this.age, this.constellation, this.professional, this.bgColor, this.fontStyle, this.isCenter: false}) : super(key: key); Widget _buildChip(str,Color tempColor) { return Container( margin: EdgeInsets.only(bottom: 5, right: 5), padding: EdgeInsets.symmetric(horizontal: 10, vertical: 3), decoration: BoxDecoration( // color: bgColor == null ? Constants.LightBlueBackgroundColor : bgColor, border: Border.all(color: Color(0xFFEC4163), width: 1), borderRadius: BorderRadius.circular(15.0), ), child: Text( str, textScaleFactor: 1.0, style: fontStyle == null ? TextStyle( fontSize: 11, color: Color(0xFFEC4163), ) : fontStyle, textAlign: TextAlign.center, ), ); } @override Widget build(BuildContext context) { return Wrap( alignment: isCenter ? WrapAlignment.center : WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.center, children: [ _buildChip(city,Color(0xff96C7FF)), _buildChip(professional,Color(0xffAC51F3)), _buildChip('$age ${I18n.of(context).years_old}-$constellation',Color(0xffF5A623)), ], ); } }