Giter VIP home page Giter VIP logo

adaptive_ui's Introduction

AdaptiveUI

A simple helper class to help you creating Adaptive UI easily.


NOTE: This will work well if you have any sort of design file. like - XD, PSD, Figma, AI, Sketch etc because you can get the design height and width from the file. Because this package depends on the actual design size.


What it does?

It provides dynamic sizes for the elements / widgets in which it's magic method is used, And it calculates the size according to the design size and the current device size.

If the design size is smaller than the current device size then it will increase the size according to current device and return the size and vice versa.

For Example

If you have a design which is 812 height * 375 width (iPhone x) and you are running your app in a device with the screen size of 1024 height * 768 width (an iPad) then it will calculate the size according to these two screen sizes.

Suppose you provided 16 size for the font which was the actual font size in the design now when you run the app inside the device of size 1024 height * 768 width then it will apply 32.768 which will be calculated by those two screen sizes.

Features

  • Adaptive Font size
  • Adaptive Height
  • Adaptive Width

Helper available

All accepts dynamic as a parameter but you will always provide int or double

Extensions

  • .sp
  • .h
  • .w

Methods

  • sp()
  • w()
  • h()

Effect

How to use

  • Install the dependency
flutter pub add adaptive_ui

Then in your constants file add two contstants as screenWidth and screenHeight and set the value as per design size, Or you can use these value directly in every page you want to make adaptive.*

* Design size the size of the design which is in XD, PSD or any file, provided by the Designer.

In your UI/Page

For example home_page.dart

import "package:adaptive_ui/adaptive_ui.dart";

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // Initialize the adaptive UI helper class
    AdaptiveUI().init(
      context: context,
      height: 812, // Design Height
      width: 375, // Design Width
    );

    return Scaffold(
      body: SafeArea(
        child: SingleChildScrollView(
          child: Container(
            width: double.infinity,
            child: Text("Adaptive UI is Awesome!"),
          ),
        ),
      ),
    );
  }
}

Now to use this

For fonts/texts

Text(
    "Some text",
    style: TextStyle(fontSize: 16.sp), // .sp extension method
),

You also can use methods intead extension

Text(
    "Some text",
    style: TextStyle(fontSize: sp(16)), // sp() helper method
),

For Height/Width

Container(
    height: 200.h, // .h extension method
    width: 200.w, // .w extension method
),

Same for the height/width you can use methods as well.

Container(
    height: h(200), // h() helper method
    width: w(200), // w() helper method
),

Thank you for using this package

adaptive_ui's People

Contributors

thedevsbuddy avatar

Stargazers

Andrii Syrokomskyi avatar

Watchers

 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.