anchored 0.0.1 copy "anchored: ^0.0.1" to clipboard
anchored: ^0.0.1 copied to clipboard

A package that provides the widget position details.

Anchored package #

A package that provides the widget position details.

Getting started #

Add dependency to pubspec.yaml file

Usage #

An example using it with TextField suffixIcon to show a Menu above it.

import 'package:anchored/anchored.dart';

class AnchoredTest extends StatelessWidget {
  const AnchoredTest({super.key});

  @override
  Widget build(BuildContext context) {
    return TextField(
      decoration: InputDecoration(
        suffixIcon: Anchored(
          anchoredBuilder: (_, anchor, anchorCenter){
            return IconButton(
              onPressed: (){
                showMenu(
                  context: context, 
                  position: RelativeRect.fromLTRB(anchor.left, anchor.top, anchor.right, anchor.bottom), 
                  items: const [
                    PopupMenuItem(child: Text("copy")),
                    PopupMenuItem(child: Text("paste")),
                  ]
                );
              }, 
              icon: const Icon(Icons.arrow_drop_down)
            );
          },
        ),
      ),
    );
  }
}

Support the plugin Buy Me A Coffee #

0
likes
110
pub points
14%
popularity

Publisher

unverified uploader

A package that provides the widget position details.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on anchored