Skip to content

Commit 27540c0

Browse files
authored
Merge pull request #276 from abhisheksharma010/main
Empty Tag
2 parents 1e23661 + 3a8435e commit 27540c0

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

lib/services/task_details.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'package:taskwarrior/widgets/pallete.dart';
1313
import 'package:taskwarrior/widgets/taskdetails.dart';
1414
import 'package:taskwarrior/widgets/taskw.dart';
1515

16+
1617
class DetailRoute extends StatefulWidget {
1718
const DetailRoute(this.uuid, {super.key});
1819

@@ -44,6 +45,7 @@ class _DetailRouteState extends State<DetailRoute> {
4445
};
4546
}
4647

48+
4749
void saveChanges() async {
4850
var now = DateTime.now().toUtc();
4951

lib/widgets/taskdetails/tags_widget.dart

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// ignore_for_file: depend_on_referenced_packages
22

33
import 'package:flutter/material.dart';
4-
54
import 'package:built_collection/built_collection.dart';
65
import 'package:google_fonts/google_fonts.dart';
76
import 'package:loggy/loggy.dart';
@@ -12,16 +11,17 @@ import 'package:taskwarrior/widgets/taskw.dart';
1211
import '../pallete.dart';
1312

1413
class TagsWidget extends StatelessWidget {
15-
const TagsWidget({
16-
required this.name,
17-
required this.value,
18-
required this.callback,
19-
super.key,
14+
const TagsWidget({
15+
required this.name,
16+
required this.value,
17+
required this.callback,
18+
super.key,
2019
});
2120

2221
final String name;
2322
final dynamic value;
2423
final void Function(dynamic) callback;
24+
2525
@override
2626
Widget build(BuildContext context) {
2727
return Card(
@@ -59,6 +59,7 @@ class TagsWidget extends StatelessWidget {
5959
class TagsRoute extends StatefulWidget {
6060
const TagsRoute({required this.value, required this.callback, super.key});
6161

62+
6263
final ListBuilder<String>? value;
6364
final void Function(ListBuilder<String>?) callback;
6465

@@ -71,13 +72,15 @@ class TagsRouteState extends State<TagsRoute> {
7172
ListBuilder<String>? draftTags;
7273

7374
void _addTag(String tag) {
74-
if (draftTags == null) {
75-
draftTags = ListBuilder([tag]);
76-
} else {
77-
draftTags!.add(tag);
75+
if (tag.isNotEmpty) { // Add this condition to ensure the tag is not empty
76+
if (draftTags == null) {
77+
draftTags = ListBuilder([tag]);
78+
} else {
79+
draftTags!.add(tag);
80+
}
81+
widget.callback(draftTags);
82+
setState(() {});
7883
}
79-
widget.callback(draftTags);
80-
setState(() {});
8184
}
8285

8386
void _removeTag(String tag) {
@@ -129,7 +132,7 @@ class TagsRouteState extends State<TagsRoute> {
129132
padding: const EdgeInsets.all(4),
130133
child: SingleChildScrollView(
131134
padding:
132-
const EdgeInsets.only(left: 10, top: 10, right: 10, bottom: 0),
135+
const EdgeInsets.only(left: 10, top: 10, right: 10, bottom: 0),
133136
child: Wrap(
134137
spacing: 8,
135138
runSpacing: 4,
@@ -161,8 +164,8 @@ class TagsRouteState extends State<TagsRoute> {
161164
: Palette.kToDark.shade200,
162165
),
163166
if (_pendingTags != null)
164-
for (var tag in _pendingTags!.entries.where((tag) =>
165-
!(draftTags?.build().contains(tag.key) ?? false)))
167+
for (var tag in _pendingTags!.entries
168+
.where((tag) => !(draftTags?.build().contains(tag.key) ?? false)))
166169
FilterChip(
167170
backgroundColor: Colors.grey.shade200,
168171
onSelected: (_) => _addTag(tag.key),

0 commit comments

Comments
 (0)