Search code examples
flutteroffset

Flutter how to set an offset, based on screen ratio, without a context?


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).


Solution

  • 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 .