pop_base_screen.dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:go_router_v7_actual/layout/default_layout.dart';

class PopBaseScreen extends StatelessWidget {
  const PopBaseScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultLayout(
      body: ListView(
        children: [
          ElevatedButton(
            onPressed: () async {
              final result = await context.push('/pop/return');

              print(result);
            },
            child: Text('Push Pop Return Screen'),
          ),
        ],
      ),
    );
  }
}

pop_return_screen.dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:go_router_v7_actual/layout/default_layout.dart';

class PopReturnScreen extends StatelessWidget {
  const PopReturnScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultLayout(
      body: ListView(
        children: [
          ElevatedButton(
            onPressed: () {
              context.pop('Code Factory');
            },
            child: Text('Pop'),
          ),
        ],
      ),
    );
  }
}

이때 pop을 하면 Code Factory라는 값을

  final result = await context.push('/pop/return');

              print(result);

result에 반환받게 되고 제대로 출력이 되는걸 알 수 있다.