My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Flutter picker view ,Set state not working

Harjit Singh's photo
Harjit Singh
·Jul 9, 2020·

3 min read

set State not working in picker

final dropdownDesignation =  MaterialButton(
  child: Text(
    selectedDesignation,
    style: style,
  ),
  height: 50,
  elevation: 0,
  color: appBackgroundColor,
  onPressed: () {
    showModalBottomSheet(
        context: context,
        builder: (BuildContext builder) {
          return Container(
            child: ListView.builder(
                itemCount: litems.length,
                itemBuilder:(BuildContext context,int index){
                return  ListTile(onTap: ()async {
                  setState(() {
                    selectedDesignation =  litems[index];
                  });

                },title:Column(crossAxisAlignment: CrossAxisAlignment.start,children: <Widget>[
                  Text(litems[index]),

                ],)

                );
            } ),
            height: MediaQuery.of(context).copyWith().size.height / 3,
          );
        });
  },
);