Skip to content

Instantly share code, notes, and snippets.

@leighajarett
Created November 4, 2022 15:18
Show Gist options
  • Save leighajarett/66e6728e204021e3b9e0190be50d014b to your computer and use it in GitHub Desktop.
Save leighajarett/66e6728e204021e3b9e0190be50d014b to your computer and use it in GitHub Desktop.
Flutter List Example
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
void main() {
runApp(
const App(),
);
}
class App extends StatelessWidget {
const App({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoApp(
home: const HomePage(),
);
}
}
class Person {
String name;
Person(this.name);
}
var items = [
Person('Person 1'),
Person('Person 2'),
Person('Person 3'),
];
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(items[index].name),
);
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment