CustomSheet: Create custom sheets with ease

I was struggling with the correct sizing of the containing arrangement with this extension. It is hinted above that the width and height set in the extension block is in dp, and not pixels.

After a little bit of investigation and trial and error, I found what was required to set the containing arrangement to the values of pixels provided.

If we get the screen density (you could use my simple extension for this), square it, then multiply it by the desired pixels, we get that size back (the desired pixel size), in the custom sheet dialog. You can extend these blocks to get the pixel values of percentage sizing at runtime.

The above will return VerticalArrangement1, in the Custom Sheet, with a height of 500 pixels and width of 320 pixels.

1 Like