D-Sibu
D-Sibu

Reputation: 71

Flutter dropdown not working on some IOS devices

I've used DropDown to select store from available store list which was working fine on android devices and also worked when i tested on iphone xs and ipads.

But on some latest ios devices i notice that the dropdown is not being triggered or even the touch is not detected. and i can't find any solution to this

here's my code that implement dropdown

 class _AddressDetailsState extends State<AddressDetails> {

  String? _selectedStoreId;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ColorConstants.cartScreenColor,
      body: Padding(
        padding: const EdgeInsets.all(
          0.0,
        ),
        child: Container(
          color: Colors.grey[100],
          padding: EdgeInsets.zero,
          child: SingleChildScrollView(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                // Dropdown for selecting a store
                BlocBuilder<StoreGroupBloc, StoreGroupState>(
                  builder: (context, state) {
                    print('StoreGroupBloc: $state');
                    if (state is StoreGroupLoading) {
                      return const Center(
                        child: CircularProgressIndicator(),
                      );
                    }
                    if (state is StoreGroupLoaded) {
                      _selectedStoreId ??= state.storeGroupData.data?.firstWhere((el)=> el?.id == StorageManager().storeDetails?.storeId)?.id;
                      // fetch user address
                      _userDetailsBloc.add(GetUserAddresses(_selectedStoreId!));
                      return Card(
                        color: Colors.grey[200], // Light-grey color
                        child: Container(
                          width: double.infinity, // Full width of the screen
                          padding:
                              EdgeInsets.all(4.0), // Adjust padding as needed

                          // Column to hold the text and dropdown
                          child: Card(
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                // Text above the dropdown
                                const Padding(
                                  padding: EdgeInsets.only(
                                      top: 16.0,
                                      left: 8.0,
                                      bottom: 8.0,
                                      right: 20.0),
                                  child: Text(
                                    'Store: ',
                                    style: TextStyle(
                                      fontSize: 18,
                                      fontWeight: FontWeight.bold,
                                    ),
                                  ),
                                ),

                                const SizedBox(
                                  height: 16.0,
                                ),
                                // DropdownButton
                                DropdownButton<String>(
                                  value: _selectedStoreId,
                                  onChanged: (String? newValue) {
                                    setState(() {
                                      _selectedStoreId = newValue;
                                    });
                                    // fetch user address
                                    _userDetailsBloc.add(
                                        GetUserAddresses(_selectedStoreId!));
                                  },
                                  // Text color
                                  underline: Container(
                                    height: 2, // Thickness of the underline
                                    color: Colors
                                        .black54, // Color of the underline
                                  ),
                                  items: [
                                    for (var store
                                        in state.storeGroupData.data ?? [])
                                      DropdownMenuItem<String>(
                                        value: store.id,
                                        child: Text(store.name ?? ''),
                                      ),
                                  ],
                                ),
                              ],
                            ),
                          ),
                        ),
                      );
                    }
                   return Container();
                  },
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Is there any alternative for this or any solution.

I try changing this to dropdown_button2 flutter package but still it gives the same problem

Upvotes: 1

Views: 31

Answers (0)

Related Questions