👨‍🏫0.8 List - список - массив

import 'package:flutter/material.dart';

class Lesson21 extends StatefulWidget {
  const Lesson21({super.key});

  @override
  State<Lesson21> createState() => _Lesson21State();
}

class _Lesson21State extends State<Lesson21> {
  // 0 , 1, 2,
  // String, int, double, bool
  String name = 'Baiastan';
  int age = 26;
  double weight = 75.87;
  bool isMarried = false;

  // Widget, Color, IconData
                       // 0         1         2
  List<String> names = ['Daniel', 'Eldiar', 'Madina', 'Darhan', 'Nursaid'];
  List<int> numbers = [709358767, 709765432];
  List<double> kg = [23.56, 76.09];
  List<bool> isLike = [true, false, true, false];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: ListView.builder(
          itemCount: names.length,
          itemBuilder: (context, index){
        return ListTile(
          leading: CircleAvatar(),
          title: Text(names[index]),
          trailing: Icon(Icons.arrow_forward_ios),
        );
      }),
    );
  }
}

Last updated