took care of compiler warnings
This commit is contained in:
parent
d6dbe5234e
commit
9d4ac739c2
|
|
@ -7,20 +7,17 @@ class AddForm extends StatefulWidget {
|
||||||
final data.Page type;
|
final data.Page type;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _AddFormState(type);
|
State<StatefulWidget> createState() => _AddFormState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AddFormState extends State<AddForm> {
|
class _AddFormState extends State<AddForm> {
|
||||||
_AddFormState(this.type);
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
final data.Page type;
|
|
||||||
int _templatChoice = -1;
|
int _templatChoice = -1;
|
||||||
String _listLabel = "";
|
String _listLabel = "";
|
||||||
String _listDesc = "";
|
String _listDesc = "";
|
||||||
List<data.List> templates = [];
|
List<data.List> templates = [];
|
||||||
|
|
||||||
final FocusNode _TemplateFocusNode = FocusNode();
|
final FocusNode _templateFocusNode = FocusNode();
|
||||||
|
|
||||||
void loadTemplates() async {
|
void loadTemplates() async {
|
||||||
var rows = await DBHelper.dbHelper.getAllLists(data.Page.templates);
|
var rows = await DBHelper.dbHelper.getAllLists(data.Page.templates);
|
||||||
|
|
@ -36,7 +33,7 @@ class _AddFormState extends State<AddForm> {
|
||||||
List<DropdownMenuItem<int>> generateDropdown() {
|
List<DropdownMenuItem<int>> generateDropdown() {
|
||||||
loadTemplates();
|
loadTemplates();
|
||||||
List<DropdownMenuItem<int>> items = [
|
List<DropdownMenuItem<int>> items = [
|
||||||
DropdownMenuItem<int>(child: Text("None"), value: -1)
|
const DropdownMenuItem<int>(child: Text("None"), value: -1)
|
||||||
];
|
];
|
||||||
templates.asMap().forEach((index, value) {
|
templates.asMap().forEach((index, value) {
|
||||||
items.add(DropdownMenuItem<int>(
|
items.add(DropdownMenuItem<int>(
|
||||||
|
|
@ -53,9 +50,9 @@ class _AddFormState extends State<AddForm> {
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(
|
title: Text(
|
||||||
'Add ' +
|
'Add ' +
|
||||||
((type == data.Page.lists)
|
((widget.type == data.Page.lists)
|
||||||
? 'Check List'
|
? 'Check List'
|
||||||
: (type == data.Page.templates)
|
: (widget.type == data.Page.templates)
|
||||||
? 'Template'
|
? 'Template'
|
||||||
: ''),
|
: ''),
|
||||||
),
|
),
|
||||||
|
|
@ -89,7 +86,7 @@ class _AddFormState extends State<AddForm> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
DropdownButtonFormField<int>(
|
DropdownButtonFormField<int>(
|
||||||
focusNode: _TemplateFocusNode,
|
focusNode: _templateFocusNode,
|
||||||
value: _templatChoice,
|
value: _templatChoice,
|
||||||
onChanged: (value) => setState(() {
|
onChanged: (value) => setState(() {
|
||||||
_templatChoice = value!;
|
_templatChoice = value!;
|
||||||
|
|
@ -103,13 +100,13 @@ class _AddFormState extends State<AddForm> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
child: Icon(Icons.save_alt),
|
child: const Icon(Icons.save_alt),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
int id = await DBHelper.dbHelper.insertList(
|
int id = await DBHelper.dbHelper.insertList(
|
||||||
data.List(
|
data.List(
|
||||||
_listLabel,
|
_listLabel,
|
||||||
isTemplate: type.index == 1,
|
isTemplate: widget.type.index == 1,
|
||||||
description: _listDesc,
|
description: _listDesc,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class BoxChecker extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: 'Flutter Demo',
|
||||||
theme: ThemeData.from(colorScheme: ColorScheme.dark()).copyWith(
|
theme: ThemeData.from(colorScheme: const ColorScheme.dark()).copyWith(
|
||||||
canvasColor: Colors.blueGrey[900],
|
canvasColor: Colors.blueGrey[900],
|
||||||
cardColor: Colors.grey[800],
|
cardColor: Colors.grey[800],
|
||||||
scaffoldBackgroundColor: Colors.black12,
|
scaffoldBackgroundColor: Colors.black12,
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,16 @@ class CheckList extends StatefulWidget {
|
||||||
final int id;
|
final int id;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _CheckList(id);
|
State<StatefulWidget> createState() => _CheckList();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CheckList extends State<CheckList> {
|
class _CheckList extends State<CheckList> {
|
||||||
_CheckList(this.id);
|
|
||||||
final int id;
|
|
||||||
bool _editable = false;
|
bool _editable = false;
|
||||||
data.List? listData;
|
data.List? listData;
|
||||||
List<data.Check> list = [];
|
List<data.Check> list = [];
|
||||||
|
|
||||||
void _loadList() async {
|
void _loadList() async {
|
||||||
var rows = await DBHelper.dbHelper.getList(id);
|
var rows = await DBHelper.dbHelper.getList(widget.id);
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -29,7 +27,7 @@ class _CheckList extends State<CheckList> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _loadListData() async {
|
void _loadListData() async {
|
||||||
var rows = await DBHelper.dbHelper.getListData(id);
|
var rows = await DBHelper.dbHelper.getListData(widget.id);
|
||||||
listData = (rows.isNotEmpty) ? data.List.fromMap(rows[0]) : null;
|
listData = (rows.isNotEmpty) ? data.List.fromMap(rows[0]) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,7 +74,8 @@ class _CheckList extends State<CheckList> {
|
||||||
onTap: () => FocusScope.of(context).unfocus(),
|
onTap: () => FocusScope.of(context).unfocus(),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text((listData != null) ? listData!.name : 'Check List: $id'),
|
title: Text(
|
||||||
|
(listData != null) ? listData!.name : 'Check List: ${widget.id}'),
|
||||||
actions:
|
actions:
|
||||||
(listData != null && listData!.isTemplate!) ? [iconButton()] : [],
|
(listData != null && listData!.isTemplate!) ? [iconButton()] : [],
|
||||||
),
|
),
|
||||||
|
|
@ -128,7 +127,7 @@ class _CheckList extends State<CheckList> {
|
||||||
title: TextFormField(
|
title: TextFormField(
|
||||||
enabled: (listData != null &&
|
enabled: (listData != null &&
|
||||||
(!listData!.isTemplate! || _editable)),
|
(!listData!.isTemplate! || _editable)),
|
||||||
decoration: InputDecoration(border: InputBorder.none),
|
decoration: const InputDecoration(border: InputBorder.none),
|
||||||
initialValue: list[index].text,
|
initialValue: list[index].text,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
list[index].text = value;
|
list[index].text = value;
|
||||||
|
|
@ -156,7 +155,8 @@ class _CheckList extends State<CheckList> {
|
||||||
if (listData!.isTemplate! && !_editable) {
|
if (listData!.isTemplate! && !_editable) {
|
||||||
ScaffoldMessenger.of(context)
|
ScaffoldMessenger.of(context)
|
||||||
..clearSnackBars()
|
..clearSnackBars()
|
||||||
..showSnackBar(SnackBar(content: Text("Template is locked")));
|
..showSnackBar(
|
||||||
|
const SnackBar(content: Text("Template is locked")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_addItem();
|
_addItem();
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ class List {
|
||||||
bool? isTemplate;
|
bool? isTemplate;
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
var map = Map<String, dynamic>();
|
var map = <String, dynamic>{};
|
||||||
if (id != null) map["id"] = this.id;
|
if (id != null) map["id"] = id;
|
||||||
map["list_name"] = this.name;
|
map["list_name"] = name;
|
||||||
if (description != null) map["list_desc"] = description;
|
if (description != null) map["list_desc"] = description;
|
||||||
if (isTemplate != null) map["is_template"] = isTemplate! ? 1 : 0;
|
if (isTemplate != null) map["is_template"] = isTemplate! ? 1 : 0;
|
||||||
return map;
|
return map;
|
||||||
|
|
@ -36,11 +36,11 @@ class Check {
|
||||||
int? listID;
|
int? listID;
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
var map = Map<String, dynamic>();
|
var map = <String, dynamic>{};
|
||||||
if (id != null) map["id"] = this.id;
|
if (id != null) map["id"] = id;
|
||||||
map["check_text"] = this.text;
|
map["check_text"] = text;
|
||||||
map["status"] = this.value ? 1 : 0;
|
map["status"] = value ? 1 : 0;
|
||||||
if (listID != null) map["list_id"] = this.listID! as int;
|
if (listID != null) map["list_id"] = listID!;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue