How to dynamically change the number of steps in stepper in flutter? - android

I am making a validation form in a stepper format in flutter. Each step has a validation form.
When first opening the page, there is only one step. I want the user to click continue and get one more stepper (i.e Step 2 and get one more step by clicking continue in step 2.)
I have tried to change the number of steps by adding one more step to the list and updating when changeCurrentStepContinue is called, but it can't increase the number of steps showing error. On going back and again going forward, I get the updated list.
So how can I change the number of steps on the same page by clicking continue in each step?

I don't know how "good" my trick is, but I just change the Key of the Stepper by adding the total amount of items in the list I'm binding to.
return Stepper(
key: Key("mysuperkey-" + items.length.toString()),
...
);
This should create a new Stepper when the total of step changes.
Cheers

Its not possible as per comment in stepper.dart that says /// The length of [steps] must not change. but I'd made some edits that works fine for vertical stepper.
Follow this steps to apply that patch into your flutter code
cd to flutter directory
download this file 0001-Made-Stepper-Stepper-Size-Dynamic.patch and keep it in flutter folder
In your terminal $ git apply 0001-Made-Stepper-Stepper-Size-Dynamic.patch
OR
Replace _buildVertical() in /flutter/packages/flutter/lib/src/material/stepper.dart with this function

Related

How to make cursor jump to specific location in Android Studio live template?

I'm trying to modify the AndroidLog live templates in Android Studio 2.2.
The default logd template expands to
android.util.Log.d(TAG, "$METHOD_NAME$: $content$");
But usually, when I am logging, I want to log the variable values and I want auto-completion to help me with it. So I modified this template to the following:
android.util.Log.d(TAG, "$METHOD_NAME$: $content$" + $content$);
However, when I expand this, the cursor still lands on the first occurrence of $content$. I want it to land on the second occurrence so Android Studio can suggest the variable name via auto completion!
For example, if I want to log the user's login time from an instance of User, the log statement would something like this
Log.d(TAG, "isSessionExpired: user.getLoginTime():" + user.getLoginTime());
So I want the cursor to be after the plus sign for auto completion to help me.
How can I achieve this with Live Templates?
Please see how soutv live template is defined, you want something similar for your logging:

Segmented Control in Android

We all know segmented control that is IOS but not in android. So I have an application that need something like that. For example let suppose I have a list of students and teacher marks the student either absent or present. and on click of each option there is a service call . for this I am using a library which is as follows:
compile 'info.hoang8f:android-segmented:1.0.6'
As I told you I have a list of students so in list I have the following case;
Case 1: If the teacher review the attendance the of last day , I fetch a list of students that are either absent or present. So on this , the segmented control that I am using in list fires the onCheckChangedlistener which run the code which is also performing some task , where as I only want to perform the task only when user change the listener. In short listener should not fire when I change any check pragmatically. and Also it fires the onCheckChangedListener multiple times. which creates problem for me :
So I have couple of question:
1) what can be used in android in place of the Segmented control library as I stated above.
2) what is possible workaround for this problem. I tried using flag but I am working in getview of listview.
this is a good library in response to what you achieve. I have used this and found the similar problem. So hence by putting flag , and making a raw check over it does a work for me . But As you are using list, i think you can not achieve what you are looking for.
I will suggest to use the radio button to get the check or you can make your custom control like this and see this library

How to print out values while debugging

In Xcode I am able to "po" any values while debugging. Is there a way to do this in Android Studio?
For example, if I hit a breakpoint and want to print out certain values in realtime as opposed to having to use Logs in my code?
You can do the following steps:
1- Set BreakPoint in the line you want to evaluate Ctrl+F8.
2- Run your code in debug mode or press Shift+F9.
3- When reached to the BreakPoint press Alt+F8 or click on the following button.
4- Then type your value in text-field and click on the Evaluate button.
References:
https://www.jetbrains.com/help/idea/debugging-code.html
https://www.jetbrains.com/help/idea/evaluating-expressions.html
Use Watches. It gives you the ability to evaluate expressions.
When you hit debug point, there are two ways to check values :
(1) Add Watch for any variable
(2) Hover over any variable, the value will be displayed there
If it's a c/c++ project, you still can use lldb command in Android Studio.
Here's the official document. When you hit the breakpoint, you will see a tab named "lldb" next to the variables tab.

Break on variable value change in Android Studio 1.1.0?

I know I could set a breakpoint at every line where my code changes the variable, but is there an option such as right-clicking a variable (to "Add to Watches") that would stop when a variable changes value?
I think C++ has this option. See this.
And Eclipse? See this.
Is this implemented in AS?
You can break on value changes of some variables in Android Studio 1.1.0.
Android Studio calls them 'Java Field Watchpoints'.
From the breakpoints windows, (Run -> "View breakpoints...") or Ctrl+Shift+F8,
you can add "Java Field Watchpoints" from the plus in the top left corner, and then select your class and variable.
If the goal is simply to set a watchpoint where execution halts if a variable's value changes, there are two methods:
Pressing Ctrl-shift-F8 to set a watchpoint brings up this dialog:
That looks more powerful but it's confusing because it lacks the option I need; and there's an extra step: filling in the dialog box below:
Once you fill it in correctly, you get the same options for stopping execution as in the simpler method below:
Define the variable on one line ending with a semicolon.
Left-click in the area where you set a normal breakpoint and up pops a dialog box.
Choose options to suit your needs.
Any instance where the value of the variable prefDbExists changes, execution will pause as at any "normal" (unconditional) breakpoint. And that's all I needed when I asked the original question.
EDIT: Fully qualified class name is {package name}.{class name})
What you seek for is commonly known as "WatchPoint".
You will find detailed answer and examples on the doc. page of JetBrains - IntelliJ - Idea which is the basis for Android Studio.
https://www.jetbrains.com/help/idea/2016.3/creating-field-watchpoints.html
For me this works perfectly !
Add a Kotlin Field Watchpoint by clicking on the space next to the line number for the field declaration in Android Studio. Select Kotlin Field Watchpoint from the Set Breakpoint menu. You will now get a breakpoint whenever that value changes.

Calabash Android: Is it possible, in a feature file, to call certain previous lines of the same feature file (re-use previous steps)?

Is it possible, in a feature file, to call certain previous lines of the same feature file?
Without using some steps of same feature file again you can use combined steps.
Ex :
Think you need to delete an order and go to home screen several times in a same feature file and for that think you need to call this 4 lines
Then I touch order cart delete order button
Then I should see delete item alert in oder cart and select YES option
Then I wait for 1 seconds
Then I go to home screen
So you need to call this 4 lines in 4 times in the same file. Instead of that you can define a new step in a ruby file like this
Then /^I delete order from ordercart$/ do
steps %{
Then I touch order cart delete order button
Then I should see delete item alert in oder cart and select YES option
Then I wait for 1 seconds
Then I go to home screen
}
end
And now you can directly delete an order using single line calling in feature file
Then I delete order from ordercart
Now you need only 4 lines instead of 16 lines and also it is easy to maintain the new changes to the code when you need in the future.
check out the 'step' command in cucumber.
In my experience though, it's a better practice to use conventional ruby method definitions and and call those from your step definitions. Steps calling other steps can get really messy.

Categories

Resources