Advertisement
Zanak

flutter item_page

May 18th, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:google_fonts/google_fonts.dart';
  3.  
  4. class ItemCard extends StatelessWidget {
  5. final String name;
  6. final int age;
  7. //// Pointer to Update Function
  8. final Function onUpdate;
  9. //// Pointer to Delete Function
  10. final Function onDelete;
  11.  
  12. ItemCard(this.name, this.age, {this.onUpdate, this.onDelete});
  13.  
  14. @override
  15. Widget build(BuildContext context) {
  16. return Container(
  17. width: double.infinity,
  18. margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
  19. padding: const EdgeInsets.all(5),
  20. decoration: BoxDecoration(
  21. borderRadius: BorderRadius.circular(8),
  22. border: Border.all(color: Colors.blue[900])),
  23. child: Row(
  24. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  25. children: [
  26. Column(
  27. crossAxisAlignment: CrossAxisAlignment.start,
  28. children: [
  29. SizedBox(
  30. width: MediaQuery.of(context).size.width * 0.5,
  31. child: Text(name,
  32. style: GoogleFonts.poppins(
  33. fontWeight: FontWeight.w600, fontSize: 16)),
  34. ),
  35. Text(
  36. "$age years old",
  37. style: GoogleFonts.poppins(),
  38. )
  39. ],
  40. ),
  41. Row(
  42. children: [
  43. SizedBox(
  44. height: 40,
  45. width: 60,
  46. child: RaisedButton(
  47. shape: CircleBorder(),
  48. color: Colors.green[900],
  49. child: Center(
  50. child: Icon(
  51. Icons.arrow_upward,
  52. color: Colors.white,
  53. )),
  54. onPressed: () {
  55. if (onUpdate != null) onUpdate();
  56. }),
  57. ),
  58. SizedBox(
  59. height: 40,
  60. width: 60,
  61. child: RaisedButton(
  62. shape: CircleBorder(),
  63. color: Colors.red[900],
  64. child: Center(
  65. child: Icon(
  66. Icons.delete,
  67. color: Colors.white,
  68. )),
  69. onPressed: () {
  70. if (onDelete != null) onDelete();
  71. }),
  72. )
  73. ],
  74. )
  75. ],
  76. ),
  77. );
  78. }
  79. }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement