Created
March 16, 2019 18:07
-
-
Save felangel/fb93c15732b5e0aced2122702eb3c8fd to your computer and use it in GitHub Desktop.
[flutter_todos] todo item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:todos_app_core/todos_app_core.dart'; | |
import 'package:flutter_todos/models/models.dart'; | |
class TodoItem extends StatelessWidget { | |
final DismissDirectionCallback onDismissed; | |
final GestureTapCallback onTap; | |
final ValueChanged<bool> onCheckboxChanged; | |
final Todo todo; | |
TodoItem({ | |
Key key, | |
@required this.onDismissed, | |
@required this.onTap, | |
@required this.onCheckboxChanged, | |
@required this.todo, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Dismissible( | |
key: ArchSampleKeys.todoItem(todo.id), | |
onDismissed: onDismissed, | |
child: ListTile( | |
onTap: onTap, | |
leading: Checkbox( | |
key: ArchSampleKeys.todoItemCheckbox(todo.id), | |
value: todo.complete, | |
onChanged: onCheckboxChanged, | |
), | |
title: Hero( | |
tag: '${todo.id}__heroTag', | |
child: Container( | |
width: MediaQuery.of(context).size.width, | |
child: Text( | |
todo.task, | |
key: ArchSampleKeys.todoItemTask(todo.id), | |
style: Theme.of(context).textTheme.title, | |
), | |
), | |
), | |
subtitle: todo.note.isNotEmpty | |
? Text( | |
todo.note, | |
key: ArchSampleKeys.todoItemNote(todo.id), | |
maxLines: 1, | |
overflow: TextOverflow.ellipsis, | |
style: Theme.of(context).textTheme.subhead, | |
) | |
: null, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment