GithubHelp home page GithubHelp logo

How to use responsive_sizer to achieve a responsive design using a Figma design with a specified phone frame? about responsive_sizer HOT 2 CLOSED

coderuni avatar coderuni commented on June 14, 2024
How to use responsive_sizer to achieve a responsive design using a Figma design with a specified phone frame?

from responsive_sizer.

Comments (2)

CoderUni avatar CoderUni commented on June 14, 2024 1

The method of approach would differ from person to person. There is no specific guideline that should follow. Since devices come in different screen sizes, screen resolutions, and screen densities, it is impossible to perfectly mimic the same figma design across multiple devices. For example, comparing two phones with the same physical height but with slightly different physical widths, the same figma design may look a little bit more squeezed in the narrow phone than the one in the wider phone.

The standard and complex approach is the web approach, which is to have set breakpoints that dictate how big the container should be. (Eg: 10px for mobile, 15px for tablet, and 20px for desktop) This approach is something that I would recommend if you have a complex flutter project and it needs to support a wide range of screens. (Mobile, Tablet, and Desktop sizes)

Note that this is time-consuming since you'd have to make 3 different layouts for each screen. See what I mean here.

Another approach that is simple would be to use percentages (which is what ResponsiveSizer helps you do). If I set my container to take 20% of a device's width, it will always take 20% of its width regardless of the device's size. We could use ratios (intended size / max size) to make similarly shaped mobile devices closely follow your figma design.

Here's an example with your 60 x 60 container. Our intended size is 60.
We start by choosing the lower value of your device frame 480 x 320 and use it (320) as our max size. Take note that the lower value here is the device's width. Since the device's width is the lower value, we will be setting the container's sizes to (intended size / max size).w.

The end result would look something like this:

Container(
   width: (60/320).w
   height: (60/320).w
)

Since this could get ugly, you could create a function or extension similar to this:

double calculateRatio(num intendedSize) => (intendedSize / maxSize).w;

from responsive_sizer.

ShubhamHande99 avatar ShubhamHande99 commented on June 14, 2024 1

Thanks for the detailed answer. I'll stick to the default percentages approach.

from responsive_sizer.

Related Issues (20)

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.