Skip to content

Instantly share code, notes, and snippets.

@nitishk72
Created April 24, 2018 12:57
Show Gist options
  • Save nitishk72/c2a731b8fd9da5d20d2baa1d5d6c9b0f to your computer and use it in GitHub Desktop.
Save nitishk72/c2a731b8fd9da5d20d2baa1d5d6c9b0f to your computer and use it in GitHub Desktop.
Simple List Builder in Flutter
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),)
],
),
),
);
}
}
@Quaker62
Copy link

Quaker62 commented Jul 8, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment