Repository: flutter
Issue: The autofill dialog can appear in the wrong place
Labels: a: text input,framework,P2,team-framework,triaged-framework

After navigating away from my form and back, the autofill dialog appears in the wrong place.  I tested this on an Android emulator, not sure about iOS.

<img width="200" src="https://user-images.githubusercontent.com/389558/178375854-9f59f14b-b729-4256-a5af-5cc967daf86f.png" />

### Steps to reproduce

  1. Run the app below, which has some autofillable fields in a route.
  2. Navigate to the route.
  3. Tap the field.  The autofill dialog shows in the correct place.
  4. Press the back button.
  5. Navigate back to the page with the field.
  6. Tap the field again.

Expected: The autofill dialog appears near the field.
Actual: It appears at the bottom left corner of the screen.

<details>

<summary>Code</summary>

```dart
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Validation Sandbox',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      initialRoute: '/',
      routes: <String, Widget Function(BuildContext)>{
        '/': (BuildContext context) => const MyHomePage(),
        LoginExample.route: (BuildContext context) => const LoginExample(),
      },
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Text Input Demos'),
      ),
      body: ListView(
        children: <Widget>[
          GestureDetector(
            onTap: () {
              Navigator.of(context).pushNamed('login');
            },
            child: const Card(
              margin: EdgeInsets.all(12.0),
              child: Padding(
                padding: EdgeInsets.all(24.0),
                child: ListTile(
                  title: Text('The form'),
                  subtitle: Text('Go here to see the autofill fields.'),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

class LoginExample extends StatelessWidget {
  const LoginExample({
    Key? key,
  }) : super(key: key);

  static const String route = 'login';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Broken autofill dialog demo'),
      ),
      body: Center(
        child: SizedBox(
          width: 300.0,
          child: _LoginForm(),
        ),
      ),
    );
  }
}

class _LoginForm extends StatefulWidget {
  @override
  _LoginFormState createState() => _LoginFormState();
}

class _LoginFormState extends State<_LoginForm> {
  final FocusNode _emailFocusNode = FocusNode();
  final FocusNode _passwordFocusNode = FocusNode();
  final FocusNode _submitFocusNode = FocusNode();

  String _email = '';
  String _password = '';

  String? _error;
  bool _loading = false;
  
  @override
  Widget build(BuildContext context) {
    return Form(
      child: Column(
        children: <Widget>[
          const SizedBox(
            height: 20.0,
          ),
          TextFormField(
            focusNode: _emailFocusNode,
            restorationId: 'email_field',
            textInputAction: TextInputAction.next,
            autofillHints: const <String>[
              AutofillHints.email,
            ],
            decoration: const InputDecoration(
              filled: true,
              icon: Icon(Icons.email),
              hintText: 'Enter your email address.',
              labelText: 'Email',
            ),
            keyboardType: TextInputType.emailAddress,
            onSaved: (String? value) {
              _email = value ?? '';
              _passwordFocusNode.requestFocus();
            },
          ),
          TextFormField(
            focusNode: _passwordFocusNode,
            restorationId: 'password_field',
            textInputAction: TextInputAction.next,
            autofillHints: const <String>[
              AutofillHints.password,
            ],
            obscureText: true,
            decoration: const InputDecoration(
              filled: true,
              icon: Icon(Icons.password),
              hintText: 'Enter your password.',
              labelText: 'Password',
            ),
            keyboardType: TextInputType.visiblePassword,
            onSaved: (String? value) {
              _password = value ?? '';
              _passwordFocusNode.requestFocus();
            },
          ),
          const SizedBox(
            height: 40.0,
          ),
          if (_loading)
            const CircularProgressIndicator(),
          if (!_loading)
            ElevatedButton(
              focusNode: _submitFocusNode,
              onPressed: () {},
              child: const Text('Submit'),
            ),
          if (_error != null)
            Text('Error: $_error'),
        ],
      ),
    );
  }
}
```

</details>