GithubHelp home page GithubHelp logo

dewminaudayashan / flutter_responsive_extension Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 274 KB

Package to achieve responsiveness in Flutter apps.

License: MIT License

Java 0.96% Objective-C 1.10% Dart 12.39% C++ 39.69% C 3.50% CMake 34.91% Swift 2.25% Shell 1.75% Kotlin 0.23% HTML 3.21%

flutter_responsive_extension's Introduction

Responsive Extension Package

The Responsive Extension package is a Flutter package that provides utilities for creating responsive UI layouts in Flutter applications. It allows developers to easily create responsive UIs that adapt to different screen sizes and orientations, such as mobile phones, tablets, web browsers, and desktops.

Inspired By

This package was inspired by the following packages:

flutter_screenutil: Provides a set of utility methods for creating responsive UIs in Flutter, with support for different screen sizes and orientations. responsive_framework: Provides a responsive layout framework for Flutter applications, allowing developers to create responsive UIs with flexible breakpoints and constraints.

Features

  • Responsive utilities: Provides methods for calculating scale factors based on device sizes, allowing for responsive UI layouts.
  • Device type detection: Provides an enum DeviceType that detects the current device type (mobile, tablet, web, or desktop) based on the screen width.
  • ResponsiveWidget: Provides a widget ResponsiveWidget that displays different widgets based on the current device type, allowing for easy adaptation of UI layouts for different devices.

Getting Started

To use the Responsive Extension package in your Flutter application, follow these steps:

Add the following import statement to your Dart file:

import 'package:responsive_extension/responsive_extension.dart';

Initialize the ResponsiveExtension:

ResponsiveExtension.initialize(context, mockSize: Size(360, 640));

You can pass an optional mockSize parameter to define a virtual size to be used as a reference for calculating scale factors. If not provided, the screen size will be used as the reference. You can also pass an optional deviceSize parameter to define a specific device size to be used for calculating scale factors. If not provided, the screen size will be used as the device size.

Use the provided extension methods and widgets in your UI layout code. For example:

Container(
  width: 100.w, // Responsive width based on the scale factor
  height: 50.h, // Responsive height based on the scale factor
  child: Text(
    'Hello',
    style: TextStyle(fontSize: 16.sp), // Responsive font size based on the scale factor
  ),
),

Use the currentDevice property to get the current device type:

DeviceType deviceType = context.currentDevice;

Use the responsiveValue method to get a responsive value based on the current device type:

double value = context.responsiveValue(
  defaultValue: 20,
  mobile: 16,
  tablet: 18,
  web: 22,
  desktop: 24,
);

Use the ResponsiveWidget to display different widgets based on the current device type:

ResponsiveWidget(
  mobile: MobileWidget(),
  tablet: TabletWidget(),
  web: WebWidget(),
  desktop: DesktopWidget(),
),

Credits

This package is inspired by the flutter_screenutil and responsive_framework packages.

flutter_responsive_extension's People

Contributors

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