1

i try to crate flutter multiple select dropdown list, i try flutter plugin multiselect, but my design not similar,how to solve this problem, i shared my code, how to get same design with multiple select drop down list. i used (flutter_custom_selector) plugin, but i need without using any plugin how to create multiple select dropdown list in flutter, my code is :

import 'package:google_fonts/google_fonts.dart';
import 'package:flutter/material.dart';

class DropDown extends StatefulWidget {
  const DropDown({Key? key}) : super(key: key);

  @override
  State<DropDown> createState() => _DropDownState();
}

class _DropDownState extends State<DropDown> {

  List<String> dataString = [
    "Pakistan",
    "Saudi Arabia",
    "UAE",
    "USA",
    "Turkey",
    "Brazil",
    "Tunisia",
    'Canada'
  ];
  String? selectedString;
  List<String>? selectedDataString;

  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;
    double height = MediaQuery.of(context).size.height;
    return Container(
      height: 120,
      width: width * 1,
      child: Padding(
        padding: const EdgeInsets.only(left: 70.0, right: 30.0, top: 10.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              "Location",
              style: GoogleFonts.poppins(
                fontSize: 16,
                color: Colors.black,
                fontWeight: FontWeight.w500,
                decoration: TextDecoration.none,
              ),
            ),
            const SizedBox(
              height: 10.0,
            ),
            Material(
              child: CustomMultiSelectField<String>(
                title: "Location",
                items: dataString,
                enableAllOptionSelect: true,
                onSelectionDone: _onCountriesSelectionComplete,
                itemAsString: (item) => item.toString(),
              ),
            ),

            
          ],
        ),
      ),
    );
  }

  void _onCountriesSelectionComplete(value) {
    selectedDataString?.addAll(value);
    setState(() {});
  }
}

and my design is Click to view Design image

Mohan Balaji
  • 29
  • 1
  • 4

0 Answers0