Skip to content

Instantly share code, notes, and snippets.

Created December 4, 2019 14:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Rendering dummy tasks in Flutter
import 'package:flutter/material.dart';
// Importing our Task class
import 'package:todo_app/task.dart';
void main() => runApp(TODOApp());
class TODOApp extends StatelessWidget {
// Creating a list of tasks with some dummy values
final List<Task> tasks = [
Task('Do homework'),
Task('Finish this tutorial')
Widget build(BuildContext context) {
return MaterialApp(
title: 'TODO app',
home: Scaffold(
appBar: AppBar(
title: Text('TODO app'),
// Using ListView.builder to render a list of tasks
body: ListView.builder(
// How many items to render
itemCount: tasks.length,
// Functions that accepts an index and renders a task
itemBuilder: (context, index) {
return ListTile(
title: Text(tasks[index].getName()),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment