| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 | import 'package:flutter/material.dart';import 'package:appflowy_popover/popover.dart';class PopoverMenu extends StatefulWidget {  @override  State<StatefulWidget> createState() => _PopoverMenuState();}class _PopoverMenuState extends State<PopoverMenu> {  final PopoverMutex exclusive = PopoverMutex();  late PopoverController firstPopover;  late PopoverController secondPopover;  @override  void initState() {    firstPopover = PopoverController(mutex: exclusive);    secondPopover = PopoverController(mutex: exclusive);    super.initState();  }  @override  Widget build(BuildContext context) {    return Container(      width: 200,      height: 200,      decoration: const BoxDecoration(color: Colors.yellow),      child: ListView(children: [        const Text("App"),        Popover(          controller: firstPopover,          offset: const Offset(10, 0),          targetAnchor: Alignment.topRight,          followerAnchor: Alignment.topLeft,          popupBuilder: (BuildContext context) {            return PopoverMenu();          },          child: TextButton(            onPressed: () {              firstPopover.show();            },            onHover: (value) {              if (value) {                firstPopover.show();              }            },            child: const Text("First"),          ),        ),        Popover(          controller: secondPopover,          offset: const Offset(10, 0),          targetAnchor: Alignment.topRight,          followerAnchor: Alignment.topLeft,          popupBuilder: (BuildContext context) {            return PopoverMenu();          },          child: TextButton(            onPressed: () {              secondPopover.show();            },            onHover: (value) {              if (value) {                secondPopover.show();              }            },            child: const Text("Second"),          ),        ),      ]),    );  }}class ExampleButton extends StatelessWidget {  final PopoverController _popover = PopoverController();  final String label;  final Alignment targetAnchor;  final Alignment followerAnchor;  final Offset? offset;  ExampleButton({    Key? key,    required this.label,    this.targetAnchor = Alignment.topLeft,    this.followerAnchor = Alignment.topLeft,    this.offset = Offset.zero,  }) : super(key: key);  @override  Widget build(BuildContext context) {    return Popover(      controller: _popover,      targetAnchor: targetAnchor,      followerAnchor: followerAnchor,      offset: offset,      child: TextButton(        onPressed: (() {          _popover.show();        }),        child: Text(label),      ),      popupBuilder: (BuildContext context) {        return PopoverMenu();      },    );  }}
 |