Last active
September 17, 2022 04:31
-
-
Save iqfareez/f69b732484ffc52bc4f34669b411a0f9 to your computer and use it in GitHub Desktop.
Example of ListView.builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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