-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.24Found to occur in 3.24Found to occur in 3.24found in release: 3.27Found to occur in 3.27Found to occur in 3.27frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-designOwned by Design Languages teamOwned by Design Languages team
Description
The MenuAnchor's child property is documented as follows:
Supply this child if there is a portion of the widget tree built in builder that doesn't depend on the controller or context supplied to the builder. It will be more efficient, since Flutter doesn't then need to rebuild this child when those change.
Expected Behavior
The builder updates each time the controller opens or closes.
Actual Behavior
The builder does not update when the controller opens, but does update when it closes.
Code Sample
import 'package:flutter/material.dart';
void main() {
runApp(
const MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MenuAnchor(
menuChildren: [
MenuItemButton(child: Text('menu item')),
],
builder: anchorBuilder,
),
),
),
),
);
}
Widget anchorBuilder(
BuildContext context,
MenuController controller,
Widget? child,
) {
final bool isOpen = controller.isOpen;
print(isOpen ? 'menu open!' : 'menu closed!');
return FilledButton(
onPressed: () {
// Using controller.isOpen is necessary here, since
// the value of isOpen does not update properly.
controller.isOpen ? controller.close() : controller.open();
},
child: Text(isOpen ? 'close menu' : 'open menu'),
);
}bleroux and navaronbracke
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.24Found to occur in 3.24Found to occur in 3.24found in release: 3.27Found to occur in 3.27Found to occur in 3.27frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-designOwned by Design Languages teamOwned by Design Languages team