Skip to content

Instantly share code, notes, and snippets.

@r3dm1ke
Created December 4, 2019 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r3dm1ke/f6d460d91e475b4d1f334f392ad7eb59 to your computer and use it in GitHub Desktop.
Save r3dm1ke/f6d460d91e475b4d1f334f392ad7eb59 to your computer and use it in GitHub Desktop.
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('Laundry'),
Task('Finish this tutorial')
];
@override
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