-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathtask.dart
51 lines (45 loc) · 1.43 KB
/
task.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
class Task {
int taskId;
String label;
bool complete;
Task({this.taskId, this.label, this.complete = false});
}
class TaskWidget extends StatelessWidget {
final String label;
final VoidCallback onDelete;
final VoidCallback onComplete;
TaskWidget({this.label, this.onDelete, this.onComplete});
Widget _buildDissmissibleBackground(
{Color color,
IconData icon,
FractionalOffset align = FractionalOffset.centerLeft}) =>
new Container(
height: 42.0,
color: color,
child: new Icon(icon, color: Colors.white70),
alignment: align,
);
@override
Widget build(BuildContext context) {
return new Container(
height: 42.0,
child: new Dismissible(
direction: DismissDirection.horizontal,
child: new Align(
alignment: FractionalOffset.centerLeft,
child: new Padding(
padding: new EdgeInsets.all(10.0), child: new Text(label))),
key: new Key(label),
background: _buildDissmissibleBackground(
color: Colors.lime, icon: Icons.check),
secondaryBackground: _buildDissmissibleBackground(
color: Colors.red,
icon: Icons.delete,
align: FractionalOffset.centerRight),
onDismissed: (direction) => direction == DismissDirection.startToEnd
? onComplete()
: onDelete()));
}
}