List - Map
// Some code
import 'package:flutter/material.dart';
class ListMapScreen extends StatefulWidget {
const ListMapScreen({super.key});
@override
State<ListMapScreen> createState() => _ListMapScreenState();
}
class _ListMapScreenState extends State<ListMapScreen> {
// Примитивыные данные
String name = 'Baiastan';
int price = 10;
double kg = 12.98;
bool isLike = true;
//Flutter data
Color green = Colors.green;
IconData favorite = Icons.favorite_border;
var surname = 'Aitmatov';
dynamic data = 34;
List<String> names = ['Baias', 'Yasin', 'Nuskayim', 'Elmirbek'];
List<int> ages = [
12,
45,
89,
90,
];
List<double> kgs = [12.87, 98.90, 78.90, 98.87];
List<bool> likes = [true, false, true];
List<Widget> children = [];
List<dynamic> datas = [12, 45.98, 'hello', true, Colors.green];
Map<String, String> dataOne = {
//Key - value
'name': 'Baiastan',
'surname': 'Aitmatov',
'address': 'Bishkek',
};
Map<String, int> dataTwo = {
'kg': 78,
'price': 109,
'age': 78,
};
Map<int, String> dataThree = {
1: 'Baiastan',
2: 'Aitmatov',
};
Map<String, bool> dataFour = {
'isLike' : true,
'isMarried': false,
};
Map<String, dynamic> person = {
'name': "Baiastan",
'surname': 'Aitmatov',
'age': 26,
'weight': 76.98,
'height': 180.0,
'isMarried': true,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Chyi',
'city': 'Bishkek',
'house': 102
}
};
List<Map<String, dynamic>> people = [
{
'name': "Baiastan",
'surname': 'Aitmatov',
'age': 26,
'weight': 76.98,
'height': 180.0,
'isMarried': false,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Chyi',
'city': 'Bishkek',
'house': 102
}
},
{
'name': "Nuskayim",
'surname': 'Nurdinova',
'age': 27,
'weight': 45,
'height': 180.0,
'isMarried': true,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Isik kul',
'city': 'Balykchi',
'house': 102
}
},
{
'name': "Baiastan",
'surname': 'Aitmatov',
'age': 26,
'weight': 76.98,
'height': 180.0,
'isMarried': true,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Chyi',
'city': 'Bishkek',
'house': 102
}
},
{
'name': "Baiastan",
'surname': 'Aitmatov',
'age': 26,
'weight': 76.98,
'height': 180.0,
'isMarried': false,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Chyi',
'city': 'Bishkek',
'house': 102
}
},
{
'name': "Nuskayim",
'surname': 'Nurdinova',
'age': 27,
'weight': 45,
'height': 180.0,
'isMarried': true,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Isik kul',
'city': 'Balykchi',
'house': 102
}
},
{
'name': "Baiastan",
'surname': 'Aitmatov',
'age': 26,
'weight': 76.98,
'height': 180.0,
'isMarried': true,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Chyi',
'city': 'Bishkek',
'house': 102
}
},
{
'name': "Baiastan",
'surname': 'Aitmatov',
'age': 26,
'weight': 76.98,
'height': 180.0,
'isMarried': false,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Chyi',
'city': 'Bishkek',
'house': 102
}
},
{
'name': "Nuskayim",
'surname': 'Nurdinova',
'age': 27,
'weight': 45,
'height': 180.0,
'isMarried': true,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Isik kul',
'city': 'Balykchi',
'house': 102
}
},
{
'name': "Baiastan",
'surname': 'Aitmatov',
'age': 26,
'weight': 76.98,
'height': 180.0,
'isMarried': true,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Chyi',
'city': 'Bishkek',
'house': 102
}
},
{
'name': "Baiastan",
'surname': 'Aitmatov',
'age': 26,
'weight': 76.98,
'height': 180.0,
'isMarried': true,
'hobbies': ['English', 'It'],
'address': {
'country': 'Kyrgyzstan',
'region': 'Chyi',
'city': 'Bishkek',
'house': 102
}
}
];
@override
Widget build(BuildContext context) {
return Scaffold(
// body: Center(
// child: Padding(
// padding: const EdgeInsets.all(40),
// child: Card(
// elevation: 10,
// child: Container(
// height: 400,
// width: double.infinity,
// color: Colors.white,
// child: Column(
// children: [
// Text(person['name'], style: TextStyle(fontSize: 20),),
// Text(person['surname'], style: TextStyle(fontSize: 20),),
// Text('${person['age']}', style: TextStyle(fontSize: 20),),
// person['isMarried'] ? Icon(Icons.markunread_rounded) : Icon(Icons.card_travel),
// Text(person['hobbies'][0]),
// Text(person['hobbies'][1]),
// Text(person['address']['country'], style: TextStyle(fontSize: 20),),
// ],
// ),
// ),
// ),
// ),
// ),
body: ListView.builder(
itemCount: people.length,
itemBuilder: (context, index){
return ListTile(
leading: Text(people[index]['name'], style: TextStyle(fontSize: 25),),
title: Text(people[index]['surname']),
subtitle: Text('${people[index]['age']}'),
trailing: Text('${people[index]['weight']}'),
);
}),
);
}
}
Last updated