import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class ItemTitle extends StatelessWidget { final String text; final String imgPath; final int moreType; final String moreText; final List> items; ItemTitle( {this.text, this.imgPath, this.moreText = "", this.moreType = 0, this.items, this.onChanged, this.onTap}); @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(left: 16.w, right: 17.w, top: 10.h, bottom: 10.h), alignment: Alignment.center, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Text( text, textAlign: TextAlign.center, style: TextStyle( color: Colors.black, fontSize: 16.sp, fontWeight: FontWeight.bold, ), ), SizedBox( width: 8.w, ), Image.asset( imgPath, width: 24.w, height: 24.h, ), ], ), if (moreText != "") buildMore() ], ), ); } final GestureTapCallback onTap; final Function(String) onChanged; Widget buildMore() { return moreType == 0 ? GestureDetector( onTap: onTap, child: Container( padding: EdgeInsets.only(left: 8.w, right: 8.w, top: 2.h, bottom: 2.h), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black.withAlpha(25), offset: Offset(0, 1), blurRadius: 12, spreadRadius: 0) ], borderRadius: BorderRadius.all(Radius.circular(2))), child: Row( children: [ Text( moreText, style: TextStyle( fontSize: 12.sp, ), ), Icon( moreType == 0 ? Icons.keyboard_arrow_right : (Icons.keyboard_arrow_down), size: 16, ) ], ), ), ) : Container( padding: EdgeInsets.only(left: 10.w, right: 10.w), child: DropdownButton( items: items, value: moreText, onChanged: onChanged, ), ); } }