toolbar.dart 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import 'package:flutter/material.dart';
  2. /// Appbar class
  3. class CustomToolbar extends StatelessWidget {
  4. CustomToolbar(
  5. {this.title,
  6. this.icon,
  7. this.onPressed,
  8. this.additionalBack,
  9. this.needBackBtn = true});
  10. final String title;
  11. final IconData icon;
  12. final Function onPressed;
  13. final bool needBackBtn;
  14. final Function additionalBack;
  15. @override
  16. Widget build(BuildContext context) {
  17. return Padding(
  18. padding: EdgeInsets.all(10),
  19. child: Row(
  20. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  21. children: <Widget>[
  22. Visibility(
  23. child: IconButton(
  24. icon: Icon(
  25. Icons.arrow_back,
  26. size: 27,
  27. color: Theme.of(context).primaryColor,
  28. ),
  29. onPressed: () {
  30. Navigator.pop(context, true);
  31. if (additionalBack != null) additionalBack();
  32. },
  33. ),
  34. visible: needBackBtn,
  35. maintainSize: true,
  36. maintainAnimation: true,
  37. maintainState: true,
  38. ),
  39. Text(
  40. title,
  41. style: TextStyle(
  42. fontSize: 26,
  43. fontWeight: FontWeight.w500,
  44. color: Theme.of(context).primaryColor),
  45. ),
  46. IconButton(
  47. icon: Icon(
  48. icon,
  49. size: 22,
  50. color: Theme.of(context).primaryColor,
  51. ),
  52. onPressed: onPressed),
  53. ],
  54. ),
  55. );
  56. }
  57. }