toolbar.dart 1.5 KB

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