Skip to content

Instantly share code, notes, and snippets.

@edsbrains
Created June 23, 2019 12:43
import 'package:flutter/material.dart';
class TaskPage extends StatefulWidget {
@override
_TaskPageState createState() => _TaskPageState();
}
class Task {
final String task;
final bool isFinish;
const Task(this.task, this.isFinish);
}
final List<Task> _taskList = [
new Task("Call Tom about appointment", false),
new Task("Fix onboarding experience", false),
new Task("Edit API documentation", false),
new Task("Setup user focus group", false),
new Task("Have coffe with Sam", true),
new Task("Meet with sales", true),
];
class _TaskPageState extends State<TaskPage> {
@override
Widget build(BuildContext context) {
return ListView.builder(
padding: const EdgeInsets.all(0),
itemCount: _taskList.length,
itemBuilder: (context, index) {
return _taskList[index].isFinish
? _taskComplete(_taskList[index].task)
: _taskUncomplete(_taskList[index].task);
},
);
}
Widget _taskUncomplete(String task) {
return Padding(
padding: const EdgeInsets.only(left: 20.0, bottom: 24.0),
child: Row(
children: <Widget>[
Icon(
Icons.radio_button_unchecked,
color: Theme.of(context).accentColor,
size: 20,
),
SizedBox(
width: 28,
),
Text(task)
],
),
);
}
Widget _taskComplete(String task) {
return Container(
foregroundDecoration: BoxDecoration(color: Color(0x60FDFDFD)),
child: Padding(
padding: const EdgeInsets.only(left: 20.0, top: 24.0),
child: Row(
children: <Widget>[
Icon(
Icons.radio_button_checked,
color: Theme.of(context).accentColor,
size: 20,
),
SizedBox(
width: 28,
),
Text(task)
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment