· 6 years ago · Sep 17, 2019, 08:32 AM
1import 'package:flutter/material.dart';
2
3class CheckBoxInListview extends StatefulWidget {
4 @override
5 _CheckBoxInListviewState createState() => _CheckBoxInListviewState();
6}
7
8class _CheckBoxInListviewState extends State<CheckBoxInListview> {
9 bool _isChecked = true;
10
11 List<String> _texts = [
12 "InduceSmile.com",
13 "Flutter.io",
14 "google.com",
15 "youtube.com",
16 "yahoo.com",
17 "gmail.com"
18 ];
19 @override
20 Widget build(BuildContext context) {
21 return Scaffold(
22 appBar: AppBar(
23 title: Text("CheckBox in ListView Example"),
24 ),
25 body: ListView(
26 padding: EdgeInsets.all(8.0),
27 children: _texts.map((text) => CheckboxListTile(
28 title: Text(text),
29 value: _isChecked,
30 onChanged: (val) {
31 setState(() {
32 _isChecked = val;
33 });
34 },
35 )).toList(),
36 ),
37 );
38 }
39}