Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.95 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class CheckBoxInListview extends StatefulWidget {
  4.   @override
  5.   _CheckBoxInListviewState createState() => _CheckBoxInListviewState();
  6. }
  7.  
  8. class _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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement