79397293

Date: 2025-01-29 15:44:38
Score: 0.5
Natty:
Report link

do like this term : just do a trinary statement to the items array like this

            DropdownButtonFormField<String>(
                                      dropdownColor: Colors.black,

                                      style: TextStyle(
                                          color:
                                              Colors.white), // Text color

                                      decoration: InputDecoration(
                                        labelStyle:
                                            TextStyle(color: Colors.white),
                                        labelText: "اختر ",
                                        border: OutlineInputBorder(),
                                      ),
                                      //van or sedan pickup_truck coupe mini_van cross_over city_car
                                      items: useOtherCar == true
                                          ? [
                                              DropdownMenuItem<String>(
                                                value: DriversCarCubit.get(
                                                        context)
                                                    .CarTypeController
                                                    .text,
                                                child: Text(
                                                  DriversCarCubit.get(
                                                          context)
                                                      .CarTypeController
                                                      .text,
                                                  style: TextStyle(
                                                      color: Colors.white),
                                                ),
                                              )
                                            ]
                                          : [
                                              'van',
                                              'sedan',
                                              'pickup_truck',
                                              'coupe',
                                              'mini_van',
                                              'cross_over',
                                              'city_car'
                                            ].map((String value) {
                                              return DropdownMenuItem<
                                                  String>(
                                                value: value,
                                                child: Text(
                                                  value,
                                                  style: TextStyle(
                                                      color: Colors.white),
                                                ),
                                              );
                                            }).toList(),
                                      value: DriversCarCubit.get(context)
                                              .CarTypeController
                                              .text ??
                                          'sedan',
                                      onChanged: (newValue) {
                                        setState(() {
                                          DriversCarCubit.get(context)
                                              .CarTypeController
                                              .text = newValue.toString();
                                        });
                                      },
                                    ),
                         
Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Low entropy (1):
  • Low reputation (1):
Posted by: Malik Muslih