Untitled

mail@pastecode.io avatar
unknown
dart
2 years ago
1.9 kB
2
Indexable
Never
import 'package:dr_turkish/helper/dimensions.dart';
import 'package:dr_turkish/helper/utils.dart';
import 'package:flutter/material.dart';

class DropDownMenuBuilder extends StatelessWidget {
  final String hint;
  final List<dynamic> list;
  final String? value;
  final void Function(String?)? onChangeFunc;

  DropDownMenuBuilder(
      {required this.hint,
      this.list = const [],
      required this.value,
      this.onChangeFunc});

  Widget build(BuildContext context) {
    return Container(
      width: Dimensions.getDesirableWidthX(90),
      height: Dimensions.getDesirableHeightX(8.0),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10),
        border: Border.all(color: MyColors().btnColor, width: 1),
      ),
      padding: EdgeInsets.all(Dimensions.getDesirableWidthX(2)),
      child: new DropdownButton<String>(
        items: list != null
            ? list.map((value) {
                return new DropdownMenuItem<String>(
                  value: value.id,
                  child: Padding(
                    padding: EdgeInsets.symmetric(
                        horizontal: Dimensions.getDesirableWidthX(2.0)),
                    child: new Text(
                      "${value.name}",
                      style: TextStyle(
                          fontSize: Dimensions.getDesirableWidth(4.0)),
                    ),
                  ),
                );
              }).toList()
            : null,
        isExpanded: true,
        value: value,
        underline: SizedBox(),
        hint: Padding(
            padding: EdgeInsets.symmetric(
                horizontal: Dimensions.getDesirableWidthX(2.0)),
            child: Text(
              "$hint",
              style: TextStyle(fontSize: Dimensions.getDesirableWidthX(4.0)),
            )),
        onChanged: onChangeFunc,
      ),
    );
  }
}