Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Create value and name array

Tags:

flutter

dart

I´m trying to create value and name array. The problem that i don´t know what is the right way for do this.

var send=[];       

    send=[
         'latitud': widget.lat;
    ];

Somebody know how can i create array with index and values?

like image 576
El Hombre Sin Nombre Avatar asked Mar 05 '19 10:03

El Hombre Sin Nombre


1 Answers

Dart uses Maps for this

to declare a map and you dont know what you will your map contain you can use

Map<String, dynamic> myObject = {'latitude': widget.lat} ;

In your Case you will need a list of objects so you can do it like that :

List<Map<String, dynamic>> send=[] ;

send.add(myObject) ;

Or :

List<Map<String, dynamic>> send=[] ;

send = [{'latitude': widget.lat}]; \\ if you want to assign it directly
like image 99
Mohamed hassan kadri Avatar answered Oct 14 '22 06:10

Mohamed hassan kadri