import 'package:flutter/material.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class SearchTitleWidget extends StatelessWidget { final String titleText; final String titleTextColor; final String iconUrl; final VoidCallback callback; const SearchTitleWidget({ this.titleText, this.titleTextColor, this.iconUrl, this.callback, }); @override Widget build(BuildContext context) { return Container( width: double.infinity, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ /// 标题 _title(), /// icon Visibility(visible: !EmptyUtil.isEmpty(iconUrl), child: _icon()), ], ), ); } Widget _title() { return Text( titleText, style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: HexColor.fromHex(titleTextColor), ), ); } Widget _icon() { return GestureDetector( onTap: callback, child: CachedNetworkImage( imageUrl: iconUrl ?? '', width: 15, fit: BoxFit.fill, ), ); } }