Created
April 24, 2018 12:57
-
-
Save nitishk72/c2a731b8fd9da5d20d2baa1d5d6c9b0f to your computer and use it in GitHub Desktop.
Simple List Builder in Flutter
This file contains 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'; | |
main()=>runApp(new MaterialApp( | |
home: new AppHome(), | |
)); | |
class AppHome extends StatefulWidget{ | |
@override | |
State<AppHome> createState() { | |
return new AppState(); | |
} | |
} | |
class AppState extends State<AppHome>{ | |
List<String> Names = [ | |
'Abhishek','John','Robert','Shyam', 'Sita','Gita','Nitish' | |
]; | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: AppBar( | |
title: new Text("My List App"), | |
), | |
body: new Container( | |
child: new ListView.builder( | |
reverse: false, | |
itemBuilder: (_,int index)=>EachList(this.Names[index]), | |
itemCount: this.Names.length, | |
), | |
), | |
); | |
} | |
} | |
class EachList extends StatelessWidget{ | |
final String name; | |
EachList(this.name); | |
@override | |
Widget build(BuildContext context) { | |
return new Card( | |
child: new Container( | |
padding: EdgeInsets.all(8.0), | |
child: new Row( | |
children: <Widget>[ | |
new CircleAvatar(child: new Text(name[0]),), | |
new Padding(padding: EdgeInsets.only(right: 10.0)), | |
new Text(name,style: TextStyle(fontSize: 20.0),) | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excelente ejercicio.
Como navegar desde cada nombre a una ruta donde esta los detalles de cada persona.
Es decir navegar desde un Item a una nueva pagina.
Pueden subir un ejemplo?