The Flutter screen ADAPTS to demomain

A global adaptation once and for all

The effect

320×480




Principle (specific codemain)

1. Change the size and devicePixelRatio of the ViewConfiguration (ViewConfiguration is assigned to RenderView, which is the root of the renderObject tree). During the layout and drawing process, the layout is drawn from the parent to the child based on the ViewConfiguration value. Default is the system devicePixelRatio, here will need to apply our values autotype initInstances () inside the UI. Window. OnPointerDataPacket = _handlePointerDataPacket Under the assignment

void _handlePointerDataPacket(ui.PointerDataPacket packet) { _pendingPointerEvents.addAll(PointerEventConverter.expand( Packet.data, // ADAPTS the conversion rate of events, using our modified getAdapterRatio());if(! locked) _flushPointerEventQueue(); }Copy the code