👨‍🏫0.9 List - список - task app

import 'package:flutter/material.dart';

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

  @override
  State<Lesson22> createState() => _Lesson22State();
}

class _Lesson22State extends State<Lesson22> {
  List<String> tasks = ['Изучить flutter', 'Learn english'];

  String name = 'Hello';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Expanded(
            child: ListView.builder(
              shrinkWrap: true,
              itemCount: tasks.length,
              itemBuilder: (context, index) {
                return ListTile(
                  leading: Checkbox(value: false, onChanged: (value) {}),
                  title: Text(tasks[index]),
                  trailing: IconButton(
                    onPressed: () {
                      setState(() {
                        tasks.removeAt(index);
                      });
                    },
                    icon: Icon(Icons.delete, color: Colors.red),
                  ),
                );
              },
            ),
          ),
        ],
      ),
    );
  }
}

Last updated