How to remove indentical ones from list dart :flutter - list

I have a list like this in my dart file:
List data = [{anjaaabq, 5:30}, {anjaaabq, 9:00}, {anjaaabq, 5:30},
{anjaaabq, 9:00},{amammama, 5:30}, {amammama, 9:00}, {anjaaabq, 5:30},
{anjaaabq, 9:00},{amammama, 5:30}, {amammama, 9:00}, {anjaaabq, 5:30},
{anjaaabq, 9:00},{amammama, 5:30}, {amammama, 9:00}, {arun, 5:30},
{arun, 9:00}];
So, I want to make this look like
[{anjaaabq, 5:30}, {anjaaabq, 9:00}, {amammama, 5:30}, {amammama, 9:00},
{arun, 5:30}, {arun, 9:00}];
How can I remove identical objects from this list?
i tried to data = data.toString
but it only showing
{{anjaaabq, 5:30}, {anjaaabq, 5:30}, {anjaaabq, 5:30}, {anjaaabq, 5:30}}
like this

You can use toSet() method, which will conver it into a set. A set is a list with unique elements. So just call this after your list:
List data = [{anjaaabq, 5:30}, {anjaaabq, 9:00}, {anjaaabq, 5:30},
{anjaaabq, 9:00},{amammama, 5:30}, {amammama, 9:00}, {anjaaabq, 5:30},
{anjaaabq, 9:00},{amammama, 5:30}, {amammama, 9:00}, {anjaaabq, 5:30},
{anjaaabq, 9:00},{amammama, 5:30}, {amammama, 9:00}, {arun, 5:30},
{arun, 9:00}];
List uniqueData = data.toSet().toList(); // will give you the list you want, with unique items.

thank you so much all at last i got the solution
List arrayTrap =[];
void main(){
data.forEach((element){
arrayTrap.add(element.toString());
});
print(arrayTrap.toSet().toList());
}```
i just convert that into string before convert in to set
so i got output like:
```[{anjaaabq, 5:30}]```

Related

Show progressbar on the top in the existing MainPage.xaml in UWP app(c++) by masking all the other controls in UI

I have an UWP C++ app for getting some information which takes a long time to load .While startup,its taking time to get the information and update the UI.So I thought of putting a progress ring while the UI is getting data. I need the progress ring to show on the UI during the loading time in MainPage.xaml thereby making the existing controls invisible.But it is not coming on top of UI.After getting data to UI,progress ring should disappear and all the controls should be visible.
<Page
x:Class="Ft_Information.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Ft_Information"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Loaded="MainWindow_Loaded" BorderThickness="10" IsTabStop="True">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid x:Name="ftnfoGrid" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="25*" />
<RowDefinition Height="500*" />
<RowDefinition Height="100*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="500*" />
<ColumnDefinition Width="800*" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1">
<TextBox x:Name="ProductNameText" x:Uid="ProductName" TextWrapping="Wrap" BorderThickness="0" IsTabStop="False" FontSize="13" IsReadOnly="True" />
<StackPanel Grid.Row="2" RenderTransformOrigin="0.5,0.5" Grid.ColumnSpan="1" HorizontalAlignment="Stretch" Margin="55,5.333,0.333,-5" VerticalAlignment="Stretch">
<ProgressRing Name="ProgressRingLbl" Height="120" Width="109" HorizontalAlignment="Left"
Foreground="Blue" IsActive="True" Visibility="Visible" VerticalAlignment="Center" Margin="0,0,0,0"/>
</StackPanel>
</Grid>
</Grid>
</Page>
MainPage::MainPage()
{
ProductNameText->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
ProgressRingLbl->IsActive = true;
ProgressRingLbl->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
MainPage::FuntouploadUI()
{
.............
//after getting data
ProgressRingLbl->IsActive = false;
ProgressRingLbl->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
ProductNameText->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
Still the progress bar is not showing anywhere in the UI.
I write a simple demo below.You can use this code in your application to test if the progress ring can show in the UI.
<Page ...>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Background="AliceBlue">
<TextBlock x:Name="MyTextBlock" Height="50" FontSize="16" Margin="0,20,0,20">Hello,world</TextBlock>​
<Button x:Name="MyButton" Click="Button_Click">click me</Button>​
<ProgressRing x:Name="MyProgressRing" Height="120" Width="109" Foreground="Blue" IsActive="True" Visibility="Visible" HorizontalAlignment="Center" VerticalAlignment="Center"></ProgressRing>​
</StackPanel>
</Grid>
</Page>
MainPage::MainPage()
{​
InitializeComponent();​
MyTextBlock->Visibility = Windows::UI::Xaml::Visibility::Collapsed;​
MyButton->Visibility = Windows::UI::Xaml::Visibility::Collapsed;​
MyProgressRing->IsActive = true;​
MyProgressRing->Visibility = Windows::UI::Xaml::Visibility::Visible;​
​
}
The reason why progress ring not working was we are using another view to show the mainpage.xaml as a child to its root grid.When I moved the progress ring part to that xaml ,it is working fine. Since progress ring is working as a seperate UI thread it is not called by the mainpage.

rCharts spiderweb plot rendered in Shiny as line plot

The spiderweb plot created using the code below renders well within the Rstudio plot panel as shown below.
However, it appears as line plot when rendered using Shiny as below.
library(rCharts)
shinyServer(function(input,output){
output$plot <- renderChart2({
plot <- Highcharts$new()
table = data.frame(id = c("a1","g3","k5","y9","z11"),
value = c(252,345,421,189,236))
plot$chart(polar = TRUE, type = "line")
plot$xAxis(categories=table$id, tickmarkPlacement= 'on', lineWidth= 0)
plot$yAxis(gridLineInterpolation= 'polygon', lineWidth= 0, min= 0)
plot$series(data = toJSONArray2(table[,c("id","value")], json = F, names = F),
name = "Series", pointPlacement="on")
plot
})
})
HTML:
<head>
<script src="js/jquery.min.js"></script>
<link rel="stylesheet" href="shared/shiny.css" type="text/css" />
<script src="shared/shiny.js" type="text/javascript"></script>
<script src="js/highcharts.js" type="text/javascript"></script>
</head>
<body>
<div id="plot" class="shiny-html-output rChart highcharts" style="width: 4px; height: 60px"></div>
<body>
Any ideas to have the plot displayed in Shiny as it should be? The plot is rendered ok according to related post but the difference is that in my case the UI is built entirely using HTML while they use ui.R instead.
What is needed is to add
<script src="js/highcharts-more.js" type="text/javascript"></script>
and it now works.

UWP development issues

I'm developing UWP app and want to set 2 columns for GridView or ListView by code.
Code:
GridView ^gView = ref new GridView();
ListView ^lView = ref new ListView();
I can't find any code or documentation how to do it programmatically. Thanks.
Yes I want 2 columns for the Grid. For example first column is property, second - data. How to achieve it by code.
I could not understand why you want to do it programmatically. In general, customizing its DataTemplate on XAML page directly is easy. For example:
<GridView ItemsSource="{Binding xx}">
<GridView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding property}"></TextBlock>
<TextBlock Grid.Column="1" Text="{Binding data}"></TextBlock>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
If you have to specify the DataTemplate programmatically, you could do like the following:
<Page.Resources>
<DataTemplate x:Key="datatemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding property}"></TextBlock>
<TextBlock Grid.Column="1" Text="{Binding data}"></TextBlock>
</Grid>
</DataTemplate>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<GridView x:Name="gd" ItemsSource="{Binding}">
</GridView>
</Grid>
public MainPage()
{
this.InitializeComponent();
gd.ItemTemplate = this.Resources["datatemplate"] as DataTemplate;
}
It's C# code, you would need to convert it to C++.

Set an image as background in ion-slide

I am trying to do an intro for an app with < ion-slides page>, my problem comes to set an image as background, I am trying to do this on my HTML:
<ion-header>
<ion-navbar>
<ion-title>Intro</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
</ion-content>
<ion-slides pager>
<ion-slide style="background-image: url(/../../www/img/fondo.png)">
<h2>Slide 1</h2>
</ion-slide>
<ion-slide style="background-color: mediumpurple">
<h2>Slide 2</h2>
</ion-slide>
<ion-slide style="background-color: mediumpurple">
<h2>Slide 3</h2>
</ion-slide>
</ion-slides>
As it can be seen, the first slide should show the image, but what I get is this:
Thanks for helping!
Your background image path is incorrect.
The image should be saved in /src/assets/img/fondo.png.
This is copied to /www/assets/img/fondo.png during the build process.
Your html code will have :
<ion-slide style="background-image: url(../assets/img/fondo.png)">
For those using Ionic 2+ I think this syntax is what you're looking for:
<ion-slide *ngFor="let imgFile of imgList" [style.backgroundImage]="'url(../assets/image/' + imgFile)">

XSLT to rename link targets in result-document()

When splitting a deeply nested XML document into multiple output files using result-document(), is there a method to rewrite the #href values to point to ids inside the new documents? For example, splitting a book into multiple documents based on each becoming a new file, named with book-part/#id. In output file for chapter 1 there may be a link to a target in output file for chapter 2, which link value used to be relative within the single file. Now this link pointing to a different file should have the file name of chapter 2 followed by # and the original target value. There are changes to make the proper linking element (related-object), too, but it is the target value that I'm trying to generate specifically.
i.e link target pattern: [outputfilename.xml]#[original-filetarget-id]
It seems that I need to gather the values of each #rid in the original file and check before I insert the filename if the target will be in a different file and write the output #document-id according to the file in which it will be output. But I'm having trouble understanding how I would know the output file name and where in the XSLT to rewrite the target.
source xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//NLM//DTD Book DTD v2.1 20050630//EN" "book.dtd">
<book dtd-version="3.0">
<book-meta>
<book-id>123.4567890</book-id>
</book-meta>
<body>
<book-part book-part-type="chapter" id="book.123.4567890.ch01">
<book-part-meta>
<title-group>
<title>Chapter 1</title>
</title-group>
</book-part-meta>
<body>
<p> some text with a <xref rid="a">link to chapter 1</xref></p>
<p> some text with a <xref rid="b">link to chapter 2</xref></p>
<p id="a">a target id in chapter 1</p>
</body>
</book-part>
<book-part book-part-type="chapter" id="book.123.4567890.ch02">
<book-part-meta>
<title-group>
<title>Chapter 2</title>
</title-group>
</book-part-meta>
<body>
<p> some text with a <xref rid="a">link to chapter 1</xref></p>
<p> some text with a <xref rid="b">link to chapter 2</xref></p>
<p id="b">a target id in chapter 1</p>
</body>
</book-part>
</body>
</book>
output book.123.4567890.ch01.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//NLM//DTD Book DTD v2.1 20050630//EN" "book.dtd">
<book dtd-version="3.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table">
<book-meta>
<book-id>123.4567890</book-id>
</book-meta>
<body>
<book-part book-part-type="chapter" id="book.123.4567890.ch01">
<book-part-meta>
<title-group>
<title>Chapter 1</title>
</title-group>
</book-part-meta>
<body>
<p> some text with a <xref rid="a">link to chapter 1</xref></p>
<p> some text with a <related-object document-type="chapter" object-id="book.123.4567890.ch02.xml#b">link to chapter 2</related-object></p>
<p id="a">a target id in chapter 1</p>
</body>
</book-part>
</body>
</book>
output book.123.4567890.ch02.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//NLM//DTD Book DTD v2.1 20050630//EN" "book.dtd">
<book dtd-version="3.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table">
<book-meta>
<book-id>123.4567890</book-id>
</book-meta>
<body>
<book-part book-part-type="chapter" id="book.123.4567890.ch02">
<book-part-meta>
<title-group>
<title>Chapter 2</title>
</title-group>
</book-part-meta>
<body>
<p> some text with a <related-object document-type="chapter" object-id="book.123.4567890.ch01.xml#a">link to chapter 1</related-object></p>
<p> some text with a <xref rid="b" >link to chapter 2</xref></p>
<p id="b">a target id in chapter 1</p>
</body>
</book-part>
</body>
</book>
The short answer is: yes, you have understood correctly what you need to do.
You need to figure out, for each hyperlink, whether its target will be in the same output file as the source of the link, or a different one. And you have correctly identified the challenge here: knowing what the new file name will be. It's not really as difficult as it may look at first; just take a deep breath and work it out.
You are at an xref element; it has an rid attribute. You want to know: will the xref and the target be in the same output file or different ones? To decide this, you must
Ascend from the xref element to the containing book-part, and figure out what its filename will be. Put this value in a variable (fn-xref).
Go to the target element (id(#rid)) and then ascend from that element to the containing book-part, and figure out what its filename will be. Put this value in a variable (fn-rid).
Compare the values of $fn-xref and $fn-rid. If they are equal, do the right thing. If they differ, do the other right thing.
I'm guessing you don't need help turning this prose description into XSLT, but speak up if you do.