Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. class SimpleBackButton extends StatelessWidget {
  2. const SimpleBackButton({
  3. Key key,
  4. this.color,
  5. this.icon,
  6. this.onPressed,
  7.  
  8. }) : super(key: key);
  9.  
  10. /// The color to use for the icon.
  11. ///
  12. /// Defaults to the [IconThemeData.color] specified in the ambient [IconTheme],
  13. /// which usually matches the ambient [Theme]'s [ThemeData.iconTheme].
  14. final Color color;
  15. final Widget icon;
  16. final VoidCallback onPressed;
  17.  
  18. @override
  19. Widget build(BuildContext context) {
  20. assert(debugCheckHasMaterialLocalizations(context));
  21. return IconButton(
  22. icon: icon ?? const BackButtonIcon(),
  23. color: color,
  24. tooltip: MaterialLocalizations.of(context).backButtonTooltip,
  25. onPressed: () {
  26. if (onPressed == null) {
  27. Navigator.maybePop(context);
  28. } else {
  29. onPressed();
  30. }
  31. },
  32. );
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement