popAndPushScreen function

Future popAndPushScreen({
  1. required BuildContext context,
  2. required Widget screen,
})

More readable than Navigator function spelled out

Implementation

Future<dynamic> popAndPushScreen({
  required BuildContext context,
  required Widget screen,
}) {
  Navigator.of(context).pop();

  return Navigator.of(context).push(
    platformPageRoute(
      context: context,
      builder: (context) => screen,
    ),
  );
}