showCountrySelectorBottomSheet method

Future<Country?> showCountrySelectorBottomSheet({
  1. required BuildContext inheritedContext,
  2. required List<Map<String, dynamic>> countries,
})

Implementation

Future<Country?> showCountrySelectorBottomSheet(
    {required BuildContext inheritedContext,
    required List<Map<String, dynamic>> countries}) {
  return showModalBottomSheet(
    context: inheritedContext,
    clipBehavior: Clip.hardEdge,
    isScrollControlled: true,
    backgroundColor: Colors.transparent,
    shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.only(
        topLeft: Radius.circular(12),
        topRight: Radius.circular(12),
      ),
    ),
    builder: (BuildContext context) {
      return GetBuilder<PhoneInputController>(builder: (logic) {
        return Stack(children: [
          GestureDetector(
            onTap: () {
              logic.resetFilter();
              Navigator.pop(context);
            },
          ),
          Padding(
            padding: EdgeInsets.only(
              bottom: MediaQuery.of(context).viewInsets.bottom,
            ),
            child: DraggableScrollableSheet(
              builder: (BuildContext context, ScrollController controller) {
                return Directionality(
                  textDirection: Directionality.of(inheritedContext),
                  child: Container(
                    decoration: ShapeDecoration(
                      color: Theme.of(context).canvasColor,
                      shape: const RoundedRectangleBorder(
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(12),
                          topRight: Radius.circular(12),
                        ),
                      ),
                    ),
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: <Widget>[
                        Padding(
                          padding: const EdgeInsets.symmetric(
                              horizontal: 8, vertical: 16),
                          child: TextFormField(
                            decoration: inputDecoration,
                            autofocus: autoFocus,
                            onChanged: (value) =>
                                logic.filterCountryMethod(value),
                          ),
                        ),
                        showCountryWithSearch(logic),
                      ],
                    ),
                  ),
                );
              },
            ),
          ),
        ]);
      });
    },
  );
}