How do I add new list tile in order in Flutter? When I add new one it is added in random order - flutter

[Numbers should go 1,2,3 not like this][1]

i don't know how your code look like but if you add a new item it will be at the top and the first item will be at bottom. the list doesn't care about the items value if its 1 or 2.
If you want them in order use sort()
https://api.dartlang.org/stable/2.6.0/dart-core/List/sort.html

Related

How to make a List that contains another list, in flutter

I was trying to make an app in flutter, I now have an app that adds a new element into a list upon pressing a FAB. Kindly let me know how can I map another ListViewBuilder to each element. I am not sure if I am being clear enough, but I am trying to be clearer. I want an app that lets you create lists inside of lists, in flutter. So for each List element, there lies a corresponding list in which the contents of the list can be added. I am a beginner, and I am struggling to figure it out. plzzz, help me out..thanks in advance...
To create a list in a list you can use:
List<List<int>> numbers = new List<List<int>>();
And then you can add a new list to this by doing:
numbers.add([0,1,2]);
This adds the list [0,1,2] to the list called numbers.
From here you can access an element in this case the second element in the first list:
x = numbers[0][1]

UIStackView, dynamically new element should always be added to the top of the list

I have one element in UIStackView. Then, I add the elements dynamically as follows.
stackView.addArrangedSubview(view)
However, they always add these elements to the end of the stackview. How can I make the new addition always add to the top?
You can just do this:
stackView.insertArrangedSubview(view, at: 0)
which inserts to view at the start.

Dismissive list view: When a widget in a list is dismissed, how do I remove a corresponding entry to an array

Currently, I have a list view that allows items within the list view to be dismissable. I want each item within that list view to correspond to an element within another list that contains text. And when that widget in the listview is dismissed, then the corresponding element in the other list also gets deleted. Does anyone know hot
What I suggest is that if there is any common thing in both list that are related to each other such as id or any else say text in your case ,After dismissible widget get triggered iterate via the second list just check if there's any common based on the 1st list item, and delete the item rebuild the state. Maybe adding some code might be better but so far this is the best way you can do. let me know if it work.

Ag-Grid expand row

Im using Ag-grid to control my table, but i want in my group that stores a list of rows instead of having to make the row group expand in 2 clicks, i want to be on 1 click.
If i click on the icon arrow it works, but if i click on the title row it only opens on 2 clicks.
I already tried to find in the documentation any information about it, but cant find nothing.
Here is a example from the documentation.
https://ag-grid.com/javascript-grid-tree/index.php
example image:
We are now recommended not to use the onGroupExpandedOrCollapsed, so this should now be...
This will also update the icons and animate the rows, which onGroupExpandedOrCollapsed won't.
onRowClicked(params) {
params.node.setExpanded(!params.node.expanded);
}
This will toggle the expansion, use params.node.setExpanded(true) if you want the rows to just stay open.
You can listen to events on either a row or cell clicked, and expand nodes accordingly.
For example to expand a row based on a click you could do the following:
onRowClicked: (params) => {
// update the node to be expanded
params.node.expanded = true;
// tell the grid to redraw based on state of nodes expanded state
gridOptions.api.onGroupExpandedOrCollapsed(params.rowIndex)
}
This should be in the documentation - I'll update it to reflect this information.
In the column definition, you can use the onCellClicked(params) function to tell it to do something when the cell is clicked. I tried looking for an expand function, but I could only find expandAll() which I don't think you will want. So what I would do is just use jquery or simple DOM selection to click on the expand icon inside of that cell.
this one works
onRowClicked(params) {
params.context.setExpand.onExpandClicked(params.rowIndex, params.node.rowHeight);
}

how to hide and unhide authoerable tabs depending upon value selected from a drop down in CQ5

i am trying to create a footer component in CQ5, where i have 4 columns & all are autherable.
But we have to make no of columns autherable too i.e based on a value selected form a dropdown we have to open those many tabs for authoring those many columns only.
i have created a dropdown and have a maximum range of 6 columns. i know that i have to configure a listener for this purpose but don't know how . Requirement is like if i select 3 from the drop down then 3 tabs should come to author 3 columns
pls help me , i am middle of something very important.i need the solution very early too as i have to finish the job as soon as possible
I might be late for this by now but in case you still need it:
You need to add a listener node before closing your drop-down element:
<listeners
jcr:primaryType="nt:unstructured"
loadcontent="function(box){ //here you also need to handle the hide/unhide when the panel loads for the first time. Use this.getValue() to retrive the intial value }"
selectionchanged="function(box, value) {
for(var c=1;c<=value;c++){
this.findParentByType('tabpanel').unhideTabStripItem("tab"+c); // You need to handle the opposite with hideTabStripItem("tab"+c);
}
}"/>
Then on both "loadcontent" and "selectionchange" (these are events on your drop-down) grab the current selected value and use it to hide/unhide the tabs. In this case the tabs would be named "tab1", "tab2", etc, make sure you get the names right.
The ExtJS in the events is finding the "tabpanel" container for the whole dialog, and then hiding/unhiding based on name. You could also set to enable/disable using the methods ".enable()" and ".setDisabled(true)". Just make sure you get the reference to the tab first if you want to do this (something like ".getComponent(tabName).enable()").
I didn't test this specific code, I couldn't find my actual example from my code base but this should take you in the right direction.