getBackNavigation method

Widget? getBackNavigation(
  1. BuildContext context
)

Returns the widget for the back navigation button.

context is required to determine the screen size and handle the button press.

Implementation

Widget? getBackNavigation(BuildContext context) {
  final WidgetSizeValues sizes = ResponsiveDesignUtils.getBackNavigationSizes(currentScreenWidth: MediaQuery.of(context).size.width);
  Widget icon = Icon(Icons.arrow_back, size: sizes.size!, color: Colors.white);

  Function? onNavigationItemClicked;

  switch (_backNavigationDestination) {
    case BackNavigationDestination.none:
      icon = Icon(Icons.logout, size: sizes.size!, color: Colors.white);
      onNavigationItemClicked = () {
        Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context) => WelcomeScreen()));
      };
      break;
  }

  return Padding(
    padding: sizes.padding!,
    child: IconButton(icon: icon, onPressed: onNavigationItemClicked == null ? null : () => onNavigationItemClicked!()),
  );
}