How to create dropdow widget when click on button? - flutter

image description here
so how to create it? I tried to find out but still can't find a way

You can simply use a dropdown widget and wrap it with visibility widget which will be updated on the basis of that button click:
bool visible=false;
ElevatedButton(onPressed: (){
visible=!visible; //onPressing the click button it will update visible variable
}, child: Text('Click')),
Visibility(
visible: visible, //which will make the dropdown visible
child: DropdownButton(items: items, onChanged: (){}))

Make use of Visibility widget
bool isDropDownVisible = false
Visibility(
visible: isDropDownVisible,
child: DropdownButton(
// DropDown Code
)
Now while onButtonClick set it as a below:
setState(() {
isCheckSelected =! isCheckSelected;
});

Related

hide floatingActionButton when scroll down and show it back when scroll up flutter

im trying to find way to hide the floatingActionButton when scroll down and show it back when scroll up
i'm using getx
Thanks in advance
1- Wrap your FloatingActionButton in a Visibility widget. This allows you to toggle the visibility of the FloatingActionButton based on a boolean value
Visibility(
visible: _isVisible, // boolean value that controls visibility
child: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
);
2- Then Create a ScrollController and attach it to a ListView. This allows you to listen for changes in the scroll position.
final ScrollController _scrollController = ScrollController();
//...
ListView.builder(
controller: _scrollController,
//...
);
3- Use the addListener method on the ScrollController to listen for changes in the scroll position and update the visibility of the FloatingActionButton accordingly.
_scrollController.addListener(() {
if (_scrollController.offset > _scrollController.position.maxScrollExtent && _isVisible) {
setState(() {
_isVisible = false;
});
} else if (_scrollController.offset <= _scrollController.position.minScrollExtent && !_isVisible) {
setState(() {
_isVisible = true;
You can make custom fab with scroll controller which is explained well in the below artile.
https://medium.com/#aakashpp/automatic-show-hide-fab-on-scroll-in-flutter-2c0abd94f3da
Please accept the solution if solved your problem

How to disable clicks detection in a CheckBox that's wrapped by an InkWell in Flutter

I have those 4 Inkwell(), inside each of them is a CheckBox(),
In the onTap: property of the InkWell() I assigned an unnamed function that does some logic.
When I click on the checkbox, the 'onTap' property of the parent InkWell isn't invoked.
What I wanna do, is when I click on the CheckBox, the onTap of the parent widget InkWell get called, so it's like disabling the CheckBox onChanged property, and letting it just like an unclickable widget.
Note: By assigning null to the onChanged property of CheckBox, the widget still absorb the click, so the onTap property of InkWell doesn't get called.
Here is my code:
InkWell(
onTap: () { /* DO SOMETHING */},
child: Row(
children: [
SizedBox( /* The flag icon */ ),
Text( /* The language name */ ),
Checkbox(
onChanged: null,
value: (selectedLanguage == widget.id) ? true : false,
)
],
),
)
You can wrap your Checkbox widget inside an IgnorePointer
IgnorePointer(
child: Checkbox(
value: selectedLanguage == widget.id,
onChanged: (v) {
// This won't get called
},
),
)

How can i make the icon change when it is clicked

I want the arrow to change and display the visibility widget when about me is clicked on the image.
About your attached image, you can simply get the effect using ExpansionTile.
How-ever to change icon based on click
create a bool _isExpanded = false inside state class.
On expand changes, use setstate to change the value.
Using assigning the icon
Icon(_isExpanded?
Icons.arrow_downward
:Icons.arrow_upward,
),
int angle = 0;
RotatedBox(
quarterTurns: angle,
child: IconButton(
icon: Icon(Icons.arrow_forward_ios),
onPressed: () {
setState(() {
angle = 1;
});
},
),
),

Long pressed menu in flutter

how to make this top bar menu when we do a long press on a card or container.
you can wrap your card widget with InkWell or GestureDetector both have longPress, then you pass a call back to your view to show the menu.
Color _colorFilterTile = Colors.transparent;
InkWell(
onLongPress: (){
//call function
setState(() {
_colorFilterTile= Colors.green.withOpacity(0.5);
});
},
child: Container(
color: _colorFilterTile,
child: ...,
),
)

How To Make a Drop down which conains grid item when cklicked in flutter

am making a category app where there will be a lot of dropdowns and on clicked it should display a list of subcategories in grid view here is a sample image of what I want to achieve.
https://cdn.dribbble.com/users/1502567/screenshots/7147539/media/dbca2b397050acac918164ddfc5820cd.jpg
That example doesn't seem like much of a dropdown, more like a container for a grid of items? I would use a Table to contain all these items. Flutter.dev has really good documentation on how to use it: https://api.flutter.dev/flutter/widgets/Table-class.html
bool pressed;
#override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
RaisedButton(
child: Text("button"),
onPressed: () {
setState(() {
pressed = true;
});
},
)
// show table if pressed is true, otherwise show an empty widget
pressed ? Table() : SizedBox(),
],
),
);
}