import 'package:flutter/material.dart'; class GradientAppBar extends StatelessWidget { final String title; final double barHeight = 50.0; IconData? iconData; GradientAppBar(this.title, {this.iconData}); @override Widget build(BuildContext context) { final double statusbarHeight = MediaQuery.of(context).padding.top; return new Container( padding: EdgeInsets.only(top: statusbarHeight), height: statusbarHeight + barHeight, child: Row( children: [ IconButton( onPressed: () { Navigator.pop(context); }, icon: Icon( Icons.arrow_back_ios, color: Colors.white, ), ), Expanded( child: Center( child: Text( title, style: TextStyle( fontSize: 20.0, color: Colors.white, fontWeight: FontWeight.bold), ), ), ), if (iconData != null) IconButton( onPressed: () {}, icon: Icon( iconData, color: Colors.white, ), ), ], ), decoration: BoxDecoration( gradient: LinearGradient( colors: [ Colors.black.withOpacity(0.4), Colors.black.withOpacity(0.2), Colors.black.withOpacity(0.0001), ], begin: Alignment.topCenter, end: Alignment.bottomCenter, tileMode: TileMode.clamp, ), ), ); } }