Flutter - Switch with more than binary values - flutter

the Switch class allows flutter developers to use a well designed binary choice widget. I would like to use a Switch Button, that allows to choose between more than just two values.
An option could be a discrete slider, but I would like to the switch button design. Is that possible?

I don't think it is possible to "create a switch with more than two values", but, there are some options to achieve what you want:
1. Use a Slider, RangeSlider or CupertinoSlider
This would allow you to select between single values from a range.
Slider, RangeSlider, and CupertinoSlider (Flutter Widget of the Week)
2. Use ToggleButtons
I this case, you can create your buttons from a list of Widgets and also a onPressed to respond when user selects a button.
Also, it has a lot of parameters to customize you buttons layout.
ToggleButtons (Flutter Widget of the Week)

Related

Create Vertical List in Flutter

I want to create this type of listview using flutter.
https://dribbble.com/shots/6872462-Food-ordering-app-Animate
You can find out more by clicking on this link. But I don't know how to create this type of list. I mean, you can see in the GIF that the list is indexed based.
A fixed indexed item container is colored.
How can I achieve it?
Flutter provides you with a widget very similar to the result you want to achieve called NavigationRail.
You will not have the animation by default, but you can maybe search in the source code of this widget how to create a custom widget that will implement animations.

Flutter nested lists - custom CheckBox

I'm really confused about this situation, I'm trying to build this app just like in the image below, the app is all about having a list of ExpansionTiles inside each one there is a list of items, each item has it's own three checkboxes[true, false, avoid], and also the ExpansionTile it self has it's own three checkboxes that can be clicked globally, instead of selecting them one by one,what I need is to get to the best solution to implement this, to know which item in which list were selected and to give a result depending on it, I'm really confused and tried many ways, many models for data, but failed, any help will be really app, I'd be more than glad with any help.enter image description here
I'd create a controlled widget for the three checkboxes, passing parameters for onChange and value (Value can be determined using an enum)
Then I'd reuse that widget everywhere I need
Then I'd go for an expansible widget that contains the list (Column widget maybe?)
Try to handle as many states as possible, having controlled widgets
Or if you're using BloC you can easily implement your core logic with this UI:)

How to make a horizonta week slider with daily view in flutter

So I am in a project and I need to make a daily view of the schedule of someone, the problem is that the same page also requires a horizontal slider of the week days, more or less. My problem is that I dont know how to make the slider, it should be something like the image, pointed out by the arrow.
The problem that I found with the libraries I tried so far is that none of tham have a customizeable slider or a slider in daily view at all. Here are the libraries.
syncfusion_flutter_calendar: ^19.2.55
flutter_week_view: ^1.1.0
weekday_selector: ^1.0.0
Is there a way to make such slider (that also changes the view below) or any libraries that can be customized and have such view?
Make a List<WeekDay> of all the weekdays you want in your slider. (you can update it dynamically)
For the Slider Widget you can use a horizontal ListView that returns your weekdaywidget for each element of the List. You can make it clickable with a GestureDetector and onTap(() {}) and set the selectedWeekday to display different tasks based on selectedWeekdaybelow.
You would have to implement the WeekDay class your self or use the DateTime class instead.

How to check visibility of a Flutter widget even when covered by another

I'm trying to find a way to check the visibility of a Flutter widget when it's either off screen or when it's obscured by another, for example Drawer, Dialog or BottomSheet.
visibility_detector helps with checking whether it's on the screen or not but does not work with the second use case (known limitation).
Is there a lower lever api that I can use to check whether a widget is actually visible to the user?
My use case: I'm adding a widget to the Overlay when something external happens (similar to Tooltip but not on long press). If the user opens for example the Drawer, the widget will appear on top. I want to detect that the child is not visible and delay or cancel the action.
Do I understand your problem?
You have a widget you want to always be on top?
You want the user to interact with that widget first before doing other things?
Use design patterns to make coding easier, your users will thank you.
You can show a Dialog on-top of other widgets with the showGeneralDialog or showDialog functions. Because Dialogs are a design-pattern used in many apps, users will already know how to use them.
Define app behavior with explicit state.
It is too hard to derive app behavior from rendered UI, not all devices are the same size and shape. This means you should try to write a variable that describes your situation and then write the code you need to make that variable's value correct. It sounds like you want a variable like bool overlayIsShowing.

Right way or difference between using setState and streamBuilder in flutter

I want to know, when we should should use streamBuilder and when we should use setState method. Should we use only one way in the project for one code style or we can use are both ways.
For example, we have radio buttons. We can handle it and to redraw after changing radio button via streamBuilder and via setState, but what way is more useful?