Advertisement
anik11556

NiceAppBar

Jul 15th, 2024 (edited)
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. class CustomAppBarr extends StatelessWidget implements PreferredSizeWidget {
  2. @override
  3. Size get preferredSize => Size.fromHeight(160.0);
  4.  
  5. @override
  6. Widget build(BuildContext context) {
  7. return AppBar(
  8. flexibleSpace: Container(
  9. decoration: BoxDecoration(
  10. gradient: LinearGradient(
  11. colors: [Color(0xFFEC407A), Color(0xFF8E24AA)],
  12. begin: Alignment.topLeft,
  13. end: Alignment.bottomRight,
  14. ),
  15. ),
  16. ),
  17. title: Padding(
  18. padding: const EdgeInsets.only(top: 18.0),
  19. child: Column(
  20. crossAxisAlignment: CrossAxisAlignment.start,
  21. children: [
  22. Text(
  23. 'Events near me',
  24. style: TextStyle(
  25. fontSize: 16,
  26. color: Colors.white70,
  27. ),
  28. ),
  29. Text(
  30. 'California, USA',
  31. style: TextStyle(
  32. fontSize: 24,
  33. fontWeight: FontWeight.bold,
  34. ),
  35. ),
  36. ],
  37. ),
  38. ),
  39. actions: [
  40. IconButton(
  41. icon: Icon(Icons.notifications, size: 30),
  42. onPressed: () {
  43. // Add notification functionality here
  44. },
  45. ),
  46. ],
  47. bottom: PreferredSize(
  48. preferredSize: Size.fromHeight(76.0), // Adjust this height if needed
  49. child: Padding(
  50. padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
  51. child: Column(
  52. children: [
  53. TextField(
  54. decoration: InputDecoration(
  55. hintText: 'Search events',
  56. prefixIcon: Icon(Icons.search, color: Colors.grey),
  57. suffixIcon: Icon(Icons.filter_alt, color: Colors.grey),
  58. filled: true,
  59. fillColor: Colors.white,
  60. border: OutlineInputBorder(
  61. borderRadius: BorderRadius.circular(30.0),
  62. borderSide: BorderSide.none,
  63. ),
  64. ),
  65. ),
  66. SizedBox(height: 20,)
  67. ],
  68. ),
  69. ),
  70. ),
  71. );
  72. }
  73. }
  74.  
  75.  
  76.  
  77. Second code:
  78. class CustomAppBar extends StatelessWidget {
  79. @override
  80. Widget build(BuildContext context) {
  81. return Container(
  82. decoration: BoxDecoration(
  83. color: Colors.blue,
  84. borderRadius: BorderRadius.only(
  85. bottomLeft: Radius.circular(35.0),
  86. bottomRight: Radius.circular(35.0),
  87. ),
  88. ),
  89. padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
  90. child: AppBar(
  91. backgroundColor: Colors.transparent,
  92. elevation: 0,
  93. title: Center(
  94. child: Text(
  95. 'Custom App Bar',
  96. style: TextStyle(
  97. fontSize: 20.0,
  98. fontWeight: FontWeight.bold,
  99. ),
  100. ),
  101. ),
  102. automaticallyImplyLeading: false,
  103. ),
  104. );
  105. }
  106. }
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement