SHARE
TWEET

Untitled

a guest Mar 12th, 2019 894 in 235 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2.  
  3. class HomeScreen extends StatefulWidget {
  4.   @override
  5.   _HomeScreenState createState() => _HomeScreenState();
  6. }
  7.  
  8. class _HomeScreenState extends State<HomeScreen> {
  9.  
  10.   List<Map<String, dynamic>> contatos=List();
  11.  
  12.  
  13.   var lista = [{
  14.     "nome": "CARLOS QUEIROZ DE SOUSA POLICARPO",
  15.     "email": "mterese0@craigslist.org",
  16.     "foto": "https://randomuser.me/api/portraits/med/men/6.jpg"
  17.   }, {
  18.     "nome": "Catherine Zecchini",
  19.     "email": "czecchini1@economist.com",
  20.     "foto": "https://randomuser.me/api/portraits/women/71.jpg"
  21.   }, {
  22.     "nome": "Veronika Rootham",
  23.     "email": "vrootham2@cyberchimps.com",
  24.     "foto": "https://randomuser.me/api/portraits/women/72.jpg"
  25.   }, {
  26.     "nome": "Nickey Hourican",
  27.     "email": "nhourican3@china.com.cn",
  28.     "foto": "https://randomuser.me/api/portraits/med/men/5.jpg"
  29.   }, {
  30.     "nome": "Jerrine Harmant",
  31.     "email": "jharmant4@psu.edu",
  32.     "foto": "https://randomuser.me/api/portraits/women/77.jpg"
  33.   }, {
  34.     "nome": "Web Lineham",
  35.     "email": "wlineham5@cbsnews.com",
  36.     "foto": "https://randomuser.me/api/portraits/med/men/9.jpg"
  37.   }, {
  38.     "nome": "Winfield Kemmons",
  39.     "email": "wkemmons6@hatena.ne.jp",
  40.     "foto": "https://randomuser.me/api/portraits/med/men/10.jpg"
  41.   }, {
  42.     "nome": "Joannes Antonsen",
  43.     "email": "jantonsen7@vinaora.com",
  44.     "foto": "https://randomuser.me/api/portraits/women/11.jpg"
  45.   }, {
  46.     "nome": "Park Rosenkrantz",
  47.     "email": "prosenkrantz8@paypal.com",
  48.     "foto": "https://randomuser.me/api/portraits/med/men/12.jpg"
  49.   }, {
  50.     "nome": "Krystle Philippsohn",
  51.     "email": "kphilippsohn9@psu.edu",
  52.     "foto": "https://randomuser.me/api/portraits/women/13.jpg"
  53.   }, {
  54.     "nome": "Hill Wapplington",
  55.     "email": "hwapplingtona@photobucket.com",
  56.     "foto": "https://randomuser.me/api/portraits/med/men/81.jpg"
  57.   }, {
  58.     "nome": "Ruthie Kennermann",
  59.     "email": "rkennermannb@usda.gov",
  60.     "foto": "https://randomuser.me/api/portraits/women/16.jpg"
  61.   }, {
  62.     "nome": "Marlow Spalding",
  63.     "email": "mspaldingc@ca.gov",
  64.     "foto": "https://randomuser.me/api/portraits/med/men/17.jpg"
  65.   }, {
  66.     "nome": "Jarret Jolliff",
  67.     "email": "jjolliffd@e-recht24.de",
  68.     "foto": "https://randomuser.me/api/portraits/med/men/20.jpg"
  69.   }, {
  70.     "nome": "Phillis Sans",
  71.     "email": "psanse@networksolutions.com",
  72.     "foto": "https://randomuser.me/api/portraits/women/30.jpg"
  73.   }, {
  74.     "nome": "Nanni McLane",
  75.     "email": "nmclanef@printfriendly.com",
  76.     "foto": "https://randomuser.me/api/portraits/women/40.jpg"
  77.   }, {
  78.     "nome": "Patten Billham",
  79.     "email": "pbillhamg@salon.com",
  80.     "foto": "https://randomuser.me/api/portraits/med/men/45.jpg"
  81.   }, {
  82.     "nome": "Obadiah Moreland",
  83.     "email": "omorelandh@people.com.cn",
  84.     "foto": "https://randomuser.me/api/portraits/med/men/65.jpg"
  85.   }, {
  86.     "nome": "Frazer Sweatman",
  87.     "email": "fsweatmani@icio.us",
  88.     "foto": "https://randomuser.me/api/portraits/med/men/19.jpg"
  89.   }, {
  90.     "nome": "Sydney Coggell",
  91.     "email": "scoggellj@walmart.com",
  92.     "foto": "https://randomuser.me/api/portraits/women/79.jpg"
  93.   }];
  94.  
  95.  
  96.   @override
  97.   void initState() {
  98.     super.initState();
  99.     for(int i=0; i< lista.length; i++){
  100.         contatos.add(lista[i]);
  101.     }
  102.   }
  103.  
  104.   @override
  105.   Widget build(BuildContext context) {
  106.     return Scaffold(
  107.       resizeToAvoidBottomPadding: true,
  108.       appBar: AppBar(
  109.         title: Text("Contatos"),
  110.         centerTitle: true,
  111.       ),
  112.       body: ListView.builder(
  113.         padding: EdgeInsets.zero,
  114.         shrinkWrap: true,
  115.         scrollDirection: Axis.vertical,
  116.         itemCount: contatos.length,
  117.         itemBuilder: (BuildContext context, index){
  118.           return _ContatoCard(context, index);
  119.         }
  120.       ),
  121.     );
  122.   }
  123.  
  124.   Widget _ContatoCard(context, int index){
  125.     return GestureDetector(
  126.       child: Card(
  127.         child: Padding(
  128.           padding: EdgeInsets.all(10.0),
  129.             child: Row(
  130.               children: <Widget>[
  131.                 Container(
  132.                   width: 70.0,
  133.                   height: 70.0,
  134.                   decoration: BoxDecoration(
  135.                       shape: BoxShape.circle,
  136.                       image: DecorationImage(
  137.                           image: NetworkImage(contatos[index]["foto"])
  138.                       )
  139.                   ),
  140.                 ),
  141.                 Padding(
  142.                   padding: EdgeInsets.only(left: 10.0),
  143.                 ),
  144.                 Expanded(
  145.                   child: Column(
  146.                     crossAxisAlignment: CrossAxisAlignment.start,
  147.                     children: <Widget>[
  148.                       Text(contatos[index]["nome"],
  149.                           style: TextStyle(
  150.                               fontSize: 18.0,
  151.                               fontWeight: FontWeight.w600
  152.                           )
  153.                       ),
  154.                       Text(contatos[index]["email"],
  155.                           style: TextStyle(
  156.                             fontSize: 16.0,
  157.                           )
  158.                       )
  159.                     ],
  160.                   ),
  161.                 )
  162.               ],
  163.             ),
  164.         ),
  165.       ),
  166.     );
  167.   }
  168. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top