You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tangheem/lib/widgets/common_dropdown_button.dart

86 lines
3.1 KiB
Dart

import 'package:flutter/material.dart';
import 'dart:math' as math;
import 'package:tangheem/classes/colors.dart';
class CommonDropDownButton extends StatelessWidget {
final int index;
final String hintText;
final String icon;
final Color iconColor;
final Color color;
final bool isDropDown;
final VoidCallback onPressed;
final Function(int) onSelect;
final double widthHeight;
final List<String> list;
CommonDropDownButton(this.index, {Key key, this.onPressed, this.isDropDown = true, this.hintText = "", this.color, this.icon, this.widthHeight, this.iconColor, this.onSelect, this.list})
: super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
onTap: onPressed,
child: Container(
height: 48,
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(10), border: Border.all(color: ColorConsts.brownColor, width: .5)),
padding: EdgeInsets.fromLTRB(24, 12, 24, 12),
child: DropdownButtonHideUnderline(
child: DropdownButton<int>(
isExpanded: isDropDown,
dropdownColor: ColorConsts.secondaryWhite,
iconSize: 0,
// icon:
hint: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Transform(
alignment: Alignment.center,
transform: Matrix4.rotationY(math.pi),
child: Icon(Icons.play_arrow_rounded, color: ColorConsts.brownColor, size: 14),
),
// SvgPicture.asset(
// icon ?? "assets/icons/drop_menu.svg",
// width: widthHeight ?? 10,
// height: widthHeight ?? 5,
// color: iconColor ?? ColorConsts.brownColor,
// ),
Text(
(list.isEmpty || index < 0) ? hintText : list[index],
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14, color: ColorConsts.brownColor, height: 14 / 17),
),
],
),
focusColor: Colors.white,
style: TextStyle(color: Colors.white),
items: !isDropDown
? []
: [
for (int i = 0; i < list.length; i++)
DropdownMenuItem<int>(
value: i,
child: SizedBox(
width: double.infinity,
child: Text(
list[i],
maxLines: 1,
textDirection: TextDirection.rtl,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlack),
),
),
)
],
onChanged: onSelect,
),
),
),
);
}
}