Git Product home page Git Product logo

flutter_adapt's Introduction

flutter_adapt

基于 flutter 的屏幕适配方案

19 年时 flutter 项目中自己封装的对于屏幕适配的工具类,最近更新了一丢丢 🤏 内容

个人观点: 对于屏幕的适配,无非就是获取当前设备的 dpi、width、height、safe area 等与 UI Design 进行比值换算。对于流式布局这种方法很通用,但是牵扯到单屏(整屏)显示,这种方法就不太满足 UI 要求。目前对于单屏显示我想到的解决方案就是:使用不同宽高比值对 UI 中元素定向处理,代码见

通过 Adapt 工具适配如下

流式布局

主要使用adaptPx(x)进行页面适配

iPhone 5s iPhone 8 iPhone 12 Pro

单屏布局

主要使用adaptPx(x)adaptPm(x)adaptDynamic(flag, x)结合进行页面适配 根据单屏内容优先级对布局尺寸进行特殊处理

例如(并不是唯一优先级)

  • 1、 width 使用adaptPx进行适配
  • 2、 height、padding、margin 使用adaptPm进行适配
  • 3、 公用动态组件 使用adaptDynamic进行适配
iPhone 5s iPhone 8 iPhone 12 Pro

flutter_adapt's People

Contributors

ohxxx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.