Created
May 13, 2022 15:08
-
-
Save behzodfaiziev/c83ba8c1f2e98aac0d553836b3ac8a54 to your computer and use it in GitHub Desktop.
How can I solve a problem with the "Checkbox" icon?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() => runApp(const MaterialApp(home: ToDo())); | |
| class ToDo extends StatelessWidget { | |
| const ToDo({Key? key}) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: const Text("To-Do-App"), | |
| backgroundColor: const Color.fromRGBO(35, 152, 185, 100), | |
| ), | |
| body: Column( | |
| children: const <Widget>[ | |
| ToDoItem("Tomate"), | |
| ToDoItem("Käse"), | |
| ToDoItem("Lauch"), | |
| ToDoItem("Paprika"), | |
| ToDoItem("Wein"), | |
| ], | |
| )); | |
| } | |
| } | |
| class ToDoItem extends StatefulWidget { | |
| final String title; | |
| const ToDoItem( | |
| this.title, { | |
| Key? key, | |
| }) : super(key: key); | |
| @override | |
| State<ToDoItem> createState() => _ToDoItemState(); | |
| } | |
| class _ToDoItemState extends State<ToDoItem> { | |
| bool isChecked = false; | |
| @override | |
| Widget build(BuildContext context) { | |
| return Container( | |
| padding: const EdgeInsets.symmetric(horizontal: 22), | |
| child: ListTile( | |
| contentPadding: const EdgeInsets.symmetric(vertical: 8.0), | |
| leading: Checkbox( | |
| onChanged: (bool? value) { | |
| setState(() { | |
| isChecked = !isChecked; | |
| }); | |
| }, | |
| value: isChecked, | |
| ), | |
| title: Text( | |
| widget.title, | |
| style: const TextStyle( | |
| fontSize: 18.0, | |
| fontWeight: FontWeight.w600, | |
| color: Colors.black54), | |
| ), | |
| trailing: const Icon(Icons.delete_outline), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment