merging two maps/list for json body in flutter - flutter

I don't know if my question will be clear but here's my question.
i have here a print of a list as you can see below.
as you can see, those in the red border is a duplicate. while I plan that the yellow borders be combined in a single list since they have a duplicate header (red border).
Result list should look something like this (combined):
[2022-177916, Installing Cut-Out, WEXEC, 2022-03-22 00:37:26.000Z, CP, LEXT, , , 212618, [2034132, CUT-OUTS, HT FUSE, 100A, 36KV, 170KV BIL, 1.0, 0.0, 1.0, -88.0, , UNIT, false, false, 0.0, 0.0, 0.0, 2035103, FUSELINK, 3K, 1.0, 0.0, 1.0, -10.0, , PC, false, false, 0.0, 0.0, 0.0]]
Here, yellow bordered data are now in a single list. then the duplicate (red border) was combined.
Hope someone could guide me in the right direction. im stuck :(
Edit:
More info on the codes below.
List<ChildrenCreateMRO> mroTempChildrenCreateSend = []; //this is the list i declared
I made a listview.builder wherein each item has a checkbox. if the user taps the checkbox, then I add some data to the list by using mroTempChildrenCreateSend.add()
so the list grows but i have several duplicates.
the sample output above was from two checked checkboxes.

Use the spread operator.
For example: final newList = [...list1, ...list2, ...list3];
list1 is the name of one of the lists, and so on. the ... is the spread operator, dropping all of the contents into the new list.
Please update your question with the code so I can better answer the question.

Related

FL Chart vertical dotted lines independent from dots

I am using FLChart in my app to display some charts. That is working just fine. However I would like to be able to draw some vertical dotted lines into my graph like this:
As you can see, some of them should also have Numbers on top of them. Ive searched for quite some time now but could not find anything like this.
I found somehting similar looking on their example :
But it is not quite the same. The lines should be independent from any dots. Is that possible?
If I understand your goal correctly, you simply want to get the result of the given example except for the dots for each data point.
You can get rid of the points by changing the FlDotData passed to the TouchedSpotIndicatorData. Going back to the example code you linked, you could replace:
FlDotData(
show: true,
getDotPainter: (spot, percent, barData, index) =>
FlDotCirclePainter(
radius: 8,
color: lerpGradient(
barData.colors,
barData.colorStops!,
percent / 100,
),
strokeWidth: 2,
strokeColor: Colors.black,
),
),
with:
FlDotData(
show: false,
)
You can draw vertical dotted line with this code snippet. Line chart data has property named extraLinesData. You can use it like below.
return LineChartData(
extraLinesData: ExtraLinesData(verticalLines: <VerticalLine>[
VerticalLine(x: 2, color: Constants.PRIMARY_COLOR_1, dashArray: [4,4]),
],) ...,

Unity is returning material color slightly wrong

I have this mini task in my game where you need to click trophies to change color of the wood on them. I have two arrays of colors, one is an array containing all possible colors and the other one contains four colors (the answer) as follows:
I've double checked that the colors are equal between the two arrays. For example the purple in Colors-array has exactly the same r, g, b & a values as the purple in the Right Order-array.
To check whether the trophies has correct color I just loop through them and grab their material color. Then I check that color against the Right Order-array but it's not quite working. For example when my first trophy is purple it should be correct, but it's not because for some reason Unity is returning slightly different material color than excepted:
Hope somebody knows why this is happening.
When you say, they are exactly same color, I assume you are referring rgb values from Color Inspector, which are not precise values.
Now I dont know what could be causing in different values of colors but
You can write an extension method to compare the values after rounding them to closest integer.
public static class Extensions
{
public static bool CompareRGB(this Color thisColor, Color otherColor)
{
return
Mathf.RoundToInt(thisColor.r * 255) == Mathf.RoundToInt(otherColor.r * 255) &&
Mathf.RoundToInt(thisColor.b * 255) == Mathf.RoundToInt(otherColor.b * 255) &&
Mathf.RoundToInt(thisColor.g * 255) == Mathf.RoundToInt(otherColor.g * 255);
}
}
usage:
Color red = Color.Red;
red.CompareRGB(Color.Red); // true;
red.CompareRGB(Color.Green); // false;
Hope this helps.
I would use a palette. This is simply an array of all the possible colors you use (sounds like you have this). Record, for each "trophy", the INDEX into this array, at the same time you assign the color to the renderer. Also, record the index for each "button", at the same time you assign the color to the renderer.
Then you can simply compare the palette index values (simple integers) to see if the color matches.

Mapbox heatmap by point value

There is an example of the heatmap https://www.mapbox.com/mapbox-gl-js/example/heatmap/ by the number of markers/points on the area. But is there a way to display a heatmap by average pins/markers values? For example if I have 5 pins and their average prop value speed=3 then it will be shown as green cluster/heatmap and if their av. prop val is 6 then it will be red cluster/heatmap.
I found that "clusterAggregates" property can help, but can't find any example of using it.
Thanks
I'll leave my way to do so. Old question, which is sometimes risen, but there are no nice sollution, so... Turf's hexgrid (http://turfjs.org/docs/#hexGrid) can help:
const hexagons = hexGrid(bbox, size);
const collection = // collection of your points;
const hexagonsWithin = collect(hexagons, collection, "propertyToAgretateFrom", "propertyToAggregateIn");
const notEmptyHexagonValues = hexagonsWithin.features.filter(({ properties }) => properties.propertyToAggregateIn.length !== 0);
const notEmptyHexagons = {
"type": "FeatureCollection",
"features": notEmptyHexagonValues,
};
// at this point you're having not empty hexagons as a geojson, which you can add to the map
collect is another method from turf, whatcollection should be you can look up in the docs, because it's changing a lot.
The general idea behind is to "divide" visible part of map (bbox) into hexagons by hexGrid method and and aggregate some properties that you need from every marker inside of every hexagon you'll have into the array, so you can get an average value, for example. And assign a color based on it.
Let's say we have feature.properties.propertyToAgretateFrom as 4 and 5 in two markers. After the aggregation, if these markers were inside one polygon, you'll have it feature.properties.propertyToAggregateIn: [4, 5] - this feature is polygon. From this on you can do pretty much everything you want.

4D data in Cesium

I'm working on a project with hourly data for some buildings of different areas.
I have asked this question is the Cesium forum, but got no answer.
Check link Here.
The idea is that I need to represent these data sets in CZML.
The data has different values for each hour of the year of each building.
these values are energy kilowatt values.
To explain it further:
Each building, has an energy value, that changes every hour.
Different buildings will have different values for the same hour!
So an example:
for A building I have the following:
"hour_1" : 0.0, "hour_2" : 0.0, "hour_3" : 0.0, "hour_4" : 0.0, "hour_5" : 0.0, "hour_6" : 0.0, "hour_7" : 0.0, "hour_8" : 0.0, "hour_9" : 1.0, "hour_10" : 29.1265, "hour_11" : 55.0334, "hour_12" : 68.0527
I need the "color" to change for each building, at each hour depending on the value it has in the attribute table.
Is it possible to be represented in CZML data?
or what other alternatives can be used with Cesium?
Thank you in advance.
-Ayah

Change text color in knitr for Word

I have an R Markdown file that outputs a data table into Word (unfortunately, my company's security settings won't allow it to interface with LaTeX) and I would like to color code the text in the table based on a classification factor to make it more readable. For example:
df <- data.frame(c(1:5), runif(5, 100, 200), c(rep("A", 3), rep("B", 2)))
colnames(df) <- c("N", "Value", "Category"
kable(df, format = "markdown", row.names = FALSE, align = 'l')
I would like whatever has a Category value of B, for example to be red in the output. I haven't found a command in knitr for Word that allows colors to change (I think this problem would be doable with LaTeX) which may stop me right there. Any thoughts or ideas how to get this to work?