Ad

Flutter How To Set An Offset, Based On Screen Ratio, Without A Context?

- 1 answer

I want to get the Offset of the middle of the screen, without using context. Is that possible?

Instead of working with pixels, I want to work with screen ratio. For instance, in order to get the center of the screen, I will set the Offset as the following Offset(0.5, 0.5).

Ad

Answer

I don't think this is possible in base flutter. However the Get package allows you to do this and much much more without context https://pub.dev/packages/get .

Ad
source: stackoverflow.com
Ad