Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. import 'package:flutter/services.dart' show rootBundle;
  2. import 'dart:async';
  3. import 'dart:convert';
  4.  
  5. import 'package:homenet/pages/search_page.dart';
  6.  
  7. class PhoneBook extends StatefulWidget {
  8. @override
  9. _PhoneBookState createState() => _PhoneBookState();
  10. }
  11.  
  12. class _PhoneBookState extends State<PhoneBook> {
  13. List data;
  14. Future<String> loadJsonData() async {
  15. var jsonText = await rootBundle.loadString("data/data.json");
  16. setState(() {
  17. data = json.decode(jsonText);
  18. });
  19. return 'success';
  20. }
  21.  
  22. @override
  23. void initState() {
  24. // TODO: implement initState
  25. this.loadJsonData();
  26. }
  27.  
  28. @override
  29. Widget build(BuildContext context) {
  30. return Container(
  31. height: MediaQuery.of(context).size.height,
  32. width: MediaQuery.of(context).size.width,
  33. color: Colors.white,
  34. child: ListView.builder(
  35. itemCount: data == null ? 0 : data.length,
  36. itemBuilder: (BuildContext context, int index) {
  37. return SingleContact(
  38. name: data[index]['name'],
  39. company: data[index]['company'],
  40. cell: data[index]['cell'],
  41. office: data[index]['office'],
  42. picture: data[index]['picture'],
  43. email: data[index]['email'],
  44. );
  45. },
  46. ),
  47. );
  48. }
  49. }
  50. class SingleContact extends StatelessWidget {
  51. final name;
  52. final company;
  53. final cell;
  54. final office;
  55. final picture;
  56. final email;
  57.  
  58. SingleContact({Key key, this.name, this.company, this.cell, this.office, this.picture, this.email});
  59.  
  60. @override
  61. Widget build(BuildContext context) {
  62. return Scaffold(
  63. appBar: AppBar(
  64. backgroundColor: new Color(0xFFFA983A),
  65. title: Image.asset(
  66. 'assets/images/logo_white.png',
  67. fit: BoxFit.cover,
  68. ),
  69. elevation: 0.0,
  70. centerTitle: true,
  71. actions: <Widget>[
  72. new IconButton(
  73. icon: new Icon(Icons.search),
  74. onPressed: () {
  75. Navigator.push(context,
  76. MaterialPageRoute(builder: (context) => new SearchPage()));
  77. },
  78. ),
  79. ],
  80. ),
  81. body: Card(
  82. elevation: 5,
  83. margin: EdgeInsets.all(8.0),
  84. child: Container(
  85. padding: EdgeInsets.all(12.0),
  86. child: Column(
  87. children: <Widget>[
  88. Row(
  89. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  90. children: <Widget>[
  91. Container(
  92. height: 75,
  93. width: 75,
  94. child: ClipRRect(
  95. borderRadius: BorderRadius.circular(50.0),
  96. child: Image.asset(picture)),
  97. ),
  98. Column(
  99. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  100. crossAxisAlignment: CrossAxisAlignment.start,
  101. children: <Widget>[
  102. Text(name,
  103. style: TextStyle(
  104. fontWeight: FontWeight.bold,
  105. fontSize: 24.0
  106. ),),
  107. Text(company,
  108. style: TextStyle(
  109. fontWeight: FontWeight.normal,
  110. fontSize: 18.0
  111. )),
  112. Text(email,
  113. style: TextStyle(
  114. fontWeight: FontWeight.normal,
  115. fontSize: 18.0,
  116. color: Color(0xFFFA983A)
  117. ))
  118. ],
  119. ),
  120. FloatingActionButton(
  121. backgroundColor: Color(0xFFFA983A),
  122. mini: true,
  123. onPressed: (){},
  124. child: Icon(Icons.phone, color: Colors.white,),
  125. ),
  126. ],
  127. ),
  128. ],
  129. ),
  130. ),
  131. ),
  132. );
  133. }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement