defaultSearchDropdown static method

Widget defaultSearchDropdown({
  1. Key? key,
  2. required SearchDropdownController searchDropdownController,
})

Implementation

static Widget defaultSearchDropdown({
  Key? key,
  required SearchDropdownController searchDropdownController,
}) {
  return Material(
    color: Colors.transparent,
    borderRadius: BorderRadius.circular(10.r),
    child: AnimatedSize(
      duration: const Duration(milliseconds: 300),
      child: Padding(
        padding: EdgeInsets.symmetric(vertical: 5.h),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            DropdownSearch<DropdownModel>(
              popupBackgroundColor: Get.theme.scaffoldBackgroundColor,
              mode: Mode.DIALOG,
              popupItemBuilder: customPopupSearchItemBuilder,
              dropdownBuilder: customDropdownSearchBuilder,
              // showSelectedItems: true,
              items: searchDropdownController.items,
              itemAsString: (DropdownModel? u) => u?.text ?? "",
              compareFn: (item, selectedItem) => item?.id == selectedItem?.id,
              showSelectedItems: true,
              popupShape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(10.r),
              ),
              popupTitle: Center(
                child: Padding(
                  padding: EdgeInsets.all(10.0.spMin),
                  child: Texts.headline6(
                    searchDropdownController.label,
                  ),
                ),
              ),
              onChanged: searchDropdownController.onChange,
              selectedItem: searchDropdownController.selectedItem,
              showSearchBox: true,
              dropdownSearchDecoration: InputDecoration(
                hintText: 'Pilih ${searchDropdownController.label}',
                enabledBorder: OutlineInputBorder(
                  // width: 0.0 produces a thin "hairline" border
                  borderSide: BorderSide(
                    color: !searchDropdownController.isValid
                        ? Get.theme.colorScheme.error
                        : Get.theme.shadowColor,
                    width: 1.w,
                  ),
                  borderRadius: BorderRadius.all(
                    Radius.circular(10.r),
                  ),
                ),
                focusedBorder: OutlineInputBorder(
                  // width: 0.0 produces a thin "hairline" border
                  borderSide: BorderSide(
                      color: Get.theme.colorScheme.error, width: 1.w),
                  borderRadius: BorderRadius.all(
                    Radius.circular(10.r),
                  ),
                ),
                border: const OutlineInputBorder(),
                // label: Texts.body2(searchDropdownController.label),
                contentPadding: EdgeInsets.only(
                  top: 1.h,
                  bottom: 1.h,
                  left: 20.w,
                ),
                filled: true,
                fillColor: Get.theme.colorScheme.background,
                hintStyle: TextStyle(
                  color: Get.theme.textTheme.bodyLarge?.color,
                ),
              ),
            ),
            AnimatedSize(
              duration: const Duration(milliseconds: 300),
              child: !searchDropdownController.isValid
                  ? Padding(
                      padding: EdgeInsets.all(8.0.spMin),
                      child: Texts.caption(
                        "Wajib disertakan",
                        color: Get.theme.colorScheme.error,
                      ),
                    )
                  : const SizedBox(
                      height: 10,
                    ),
            ),
          ],
        ),
      ),
    ),
  );
}