@@ -3,6 +3,7 @@ import 'dart:async';
33import 'package:flutter/material.dart' ;
44import 'package:note_app/model/checklist/ChecklistElement.dart' ;
55import 'package:note_app/model/checklist/ChecklistManager.dart' ;
6+ import 'package:provider/provider.dart' ;
67
78class ChecklistTile extends StatefulWidget {
89 final int idx;
@@ -33,29 +34,33 @@ class _ChecklistTileState extends State<ChecklistTile> {
3334
3435 @override
3536 Widget build (BuildContext context) {
36- return ListTile (
37- leading: IconButton (
38- icon: _ticked
39- ? Icon (Icons .check_box_rounded)
40- : Icon (Icons .check_box_outline_blank_rounded),
41- onPressed: _onTapCheckbox,
42- ),
43- title: TextField (
44- controller: _controller,
45- maxLength: 100 ,
46- maxLines: null ,
47- onChanged: _onContentModified,
48- onSubmitted: _onContentSubmitted,
49- textInputAction: TextInputAction .done,
50- style: TextStyle (fontSize: 20 ),
51- decoration: InputDecoration (
52- hintText: 'Item' ,
53- border: InputBorder .none,
54- counterText: '' ,
37+ return Consumer <ChecklistManager >(builder: (context, manager, child) {
38+ _controller.text = manager.elems[widget.idx].content;
39+ _ticked = manager.elems[widget.idx].isChecked;
40+ return ListTile (
41+ leading: IconButton (
42+ icon: _ticked
43+ ? Icon (Icons .check_box_rounded)
44+ : Icon (Icons .check_box_outline_blank_rounded),
45+ onPressed: _onTapCheckbox,
5546 ),
56- ),
57- horizontalTitleGap: 0 ,
58- );
47+ title: TextField (
48+ controller: _controller,
49+ maxLength: 100 ,
50+ maxLines: null ,
51+ onChanged: _onContentModified,
52+ onSubmitted: _onContentSubmitted,
53+ textInputAction: TextInputAction .done,
54+ style: TextStyle (fontSize: 20 ),
55+ decoration: InputDecoration (
56+ hintText: 'Item' ,
57+ border: InputBorder .none,
58+ counterText: '' ,
59+ ),
60+ ),
61+ horizontalTitleGap: 0 ,
62+ );
63+ });
5964 }
6065
6166 void _onTapCheckbox () {
0 commit comments