Skip to content

Instantly share code, notes, and snippets.

@iqfareez
Last active September 17, 2022 04:31
Show Gist options
  • Save iqfareez/f69b732484ffc52bc4f34669b411a0f9 to your computer and use it in GitHub Desktop.
Save iqfareez/f69b732484ffc52bc4f34669b411a0f9 to your computer and use it in GitHub Desktop.
Example of ListView.builder
import 'package:flutter/material.dart';
List<String> list = ["A", "B", "C", "D", "E", "F"];
void main() {
return runApp(
MaterialApp(
title: 'Flutter New AppDemo',
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
return listItem(list[index]);
}),
),
),
),
);
}
Widget listItem(String text) {
return Container(
height: 100,
padding: const EdgeInsets.only(left: 16),
child: Align(
alignment: Alignment.centerLeft,
child: Text(text),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment