Repository: flutter
Issue: Offset of PopupMenuButton takes selected item into account
Labels: framework,f: material design,a: quality,has reproducible steps,P2,has partial patch,found in release: 3.7,found in release: 3.9,team-design,triaged-design

I noticed my `PopUpMenu` jumping around whenever I selected any value in it. After deeper inspection I noticed the `PopUpMenu`'s offset is linked to the `initialValue`. But this doesn't make any sense and is also not documented.

I've build a small example app to show it. The `CheckedPopUpMenu` acts normally to its given offset. But the other `PopUpMenu`'s offset is only correct when the first item is selected. If any other item is selected it jumps to the top off the screen (because the offset of the selected item is offscreen probably).
The checkbox in the middle adds the workaround I currently use, which is adding more offset relative to the selected item.

Example app code to be copy-pasted into e.g. Dartpad:

```dart
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'PupUpMenu bug',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'PupUpMenu bug'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({required this.title, super.key});

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _itemCount = 4;
  final _checkedItems = [false, false, false, false];

  int? _selectedIndex;
  bool _applyWorkaround = false;

  @override
  Widget build(BuildContext context) {
    final _checkedItemWidgets = List.generate(_itemCount, (index) {
      return CheckedPopupMenuItem(
        child: Text("Check $index"),
        checked: _checkedItems[index],
        value: index,
      );
    });

    final _itemWidgets = List.generate(_itemCount, (index) {
      return PopupMenuItem(
        child: Text("Check $index"),
        value: index,
      );
    });

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        actions: [
          PopupMenuButton(
            icon: Icon(Icons.check),
            offset: Offset(0, 100),
            onSelected: (index) {
              setState(() {
                _checkedItems[index] = !_checkedItems[index];
              });
            },
            itemBuilder: (_) => _checkedItemWidgets,
          ),
          PopupMenuButton(
            initialValue:
                _selectedIndex, // Setting this makes the offset focus on this item
            icon: Icon(Icons.close),
            offset: Offset(
                0,
                100 +
                    (_applyWorkaround ? 44 * (_selectedIndex ?? 0) : 0)
                        .toDouble()),
            onSelected: (index) {
              setState(() {
                _selectedIndex = index;
              });
            },
            itemBuilder: (_) => _itemWidgets,
          )
        ],
      ),
      body: Center(
        child: Row(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Checkbox(
                value: _applyWorkaround,
                onChanged: (checked) {
                  if (checked != null) {
                    setState(() {
                      _applyWorkaround = checked;
                    });
                  }
                }),
            SizedBox(width: 8.0),
            Text("Apply workaround"),
          ],
        ),
      ),
    );
  }
}
```

Flutter doctor output:

```
Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v1.1.9-pre.25, on Microsoft Windows [Version 10.0.17134.472], locale nl-NL)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.2)
[√] Android Studio (version 3.3)
[√] Connected device (1 available)

• No issues found!

```