widget_finder 0.1.1 copy "widget_finder: ^0.1.1" to clipboard
widget_finder: ^0.1.1 copied to clipboard

widget_finder makes it easy to find the position and size of the widget.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:widget_finder/widget_finder.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final key = GlobalKey();

  Offset? position;
  Size? size;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Widget_Finder Exampel'),
        ),
        body: Container(
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Container(
                  key: key,
                  color: Colors.red,
                  width: 200,
                  height: 300,
                ),
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: MaterialButton(
                    color: Colors.blue,
                    onPressed: () {
                      setState(() {
                        position = WidgetFinder.of(key).center;
                        size = WidgetFinder.of(key).size;
                      });
                    },
                    child: Text('Find!'),
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Text('position: $position'),
                ),
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Text('size: $size'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
8
likes
140
pub points
63%
popularity

Publisher

verified publishertykan.dev

widget_finder makes it easy to find the position and size of the widget.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on widget_finder