Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: save position of form so that it reopens on that position the next time it is opened #1

Closed
davoutuk opened this issue Feb 27, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@davoutuk
Copy link

When I drag a 'floating dialog' to a new position on the screen, is there a way of storing that new position so that when the floating dialog is opened a second time it is displayed in the saved position rather than the default?

Example scenario:
My Flutter web app includes an 'edit xxxx' feature that will display a floating dialog
The user may wish to drag the floating dialog to a new position in the web app display so that they can see the details on the main display
That drag position should become the new starting position for the 'edit xxxx' floating dialog.

@doonfrs
Copy link
Owner

doonfrs commented Feb 27, 2024

Thank you for the feedback,
Please update to the latest version ( published to the pub.dev ) to use onDrag callback

  • You can use dialogLeft, dialogRight to set the starting position of the dialog.
  • Save the value using onDrag callback.
  • Make sure not to set autoCenter to true.

I want to keep it simple, the widget will give you the ability to save/load the latest position.
You can use Shared preferences, it is up to you.


FloatingDialog(
                  onDrag: (x, y) {
                    print('x: $x, y: $y');
                  },
                  onClose: () {
                    setState(() {
                      _showDialog = false;
                    });
                  },
                  child: const SizedBox(
                      height: 200,
                      width: 300,
                      child: Align(
                          alignment: Alignment.topCenter,
                          child: Text('Dialog Title')))),

@doonfrs doonfrs added the enhancement New feature or request label Feb 27, 2024
@doonfrs doonfrs closed this as completed Feb 27, 2024
@davoutuk
Copy link
Author

The 'onDrag' event handler allows the dragged-to position to be saved, but how do I set that x/y position into the positioning of the floating dialog the next time it is opened?

@doonfrs
Copy link
Owner

doonfrs commented Feb 27, 2024

Hi @davoutuk please re-read my reply, I answered you.

You can use dialogLeft, dialogRight to set the starting position of the dialog.

best;

@davoutuk
Copy link
Author

Brilliant ! That works really well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants