I want too many option kind of Elevated buttons in one screen, which needed to be scrollable. I have tried Row widget instead of column and gives error, I don't how to place them side by side and below according to the screen size.Pls guide me where I am going wrong? Thanks. The tried code is below:-
Container(
child: SingleChildScrollView(
child: Column(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 70, vertical: 20),
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: hobbieslist.length,
itemBuilder: (BuildContext context, index) {
return Padding(
padding: const EdgeInsets.all(4.0),
child: ElevatedButton(
child: Text("${hobbieslist[index]["name"]}"
,style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500,
// color: man ? mRed : Colors.blueGrey
),
),
onPressed: (){
setState(() {
if (selected.length < 3) {
hobbieslist[index]["ontap"] =
!hobbieslist[index]["ontap"];
if (hobbieslist[index]["ontap"]) {
selected.add(hobbieslist[index]["name"]);
print(hobbieslist[index]["name"]);
print(selected);
} else {
selected.remove(hobbieslist[index]["name"]);
print(selected);
}
} else {
if (hobbieslist[index]["ontap"]) {
hobbieslist[index]["ontap"] =
!hobbieslist[index]["ontap"];
selected.remove(hobbieslist[index]["name"]);
} else {
Fluttertoast.showToast( msg: "Can only select 5",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 3,
backgroundColor: Colors.blueGrey,
textColor: Colors.white,
fontSize: 16.0);
}
}
});
},
style: ElevatedButton.styleFrom(
primary: hobbieslist[index]["ontap"] ? mRed : Colors.blueGrey,
onPrimary: white,
elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.7)
),
),
)
);
},
),
),
],
),
),
),