ResponsiveFramework

2025-12-11 0 268

Responsive Framework

Responsiveness made simple

The Responsive Framework includes widgets that help developers build responsive apps for mobile, desktop, and website layouts.

Demo

Minimal Website

A demo website built with the Responsive Framework. View Code

Flutter Website

The flutter.dev website recreated in Flutter. View Code

Pub.dev Website

The pub.dev website recreated in Flutter. View Code

Quick Start

Import this library into your project:

responsive_framework: ^latest_version

Add ResponsiveBreakpoints.builder to your MaterialApp or CupertinoApp. Define your own breakpoints and labels.

import \'package:responsive_framework/responsive_framework.dart\';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      builder: (context, child) => ResponsiveBreakpoints.builder(
        child: child!,
        breakpoints: [
          const Breakpoint(start: 0, end: 450, name: MOBILE),
          const Breakpoint(start: 451, end: 800, name: TABLET),
          const Breakpoint(start: 801, end: 1920, name: DESKTOP),
          const Breakpoint(start: 1921, end: double.infinity, name: \'4K\'),
        ],
      ),
      initialRoute: \"/\",
    );
  }
}

Use the labels you defined for layouts and values.

// Example: if the screen is bigger than the Mobile breakpoint, build full width AppBar icons and labels.
if (ResponsiveBreakpoints.of(context).largerThan(MOBILE))
    FullWidthAppBarItems()

// Booleans
ResponsiveBreakpoints.of(context).isDesktop;
ResponsiveBreakpoints.of(context).isTablet;
ResponsiveBreakpoints.of(context).isMobile;
ResponsiveBreakpoints.of(context).isPhone;

// Conditionals
ResponsiveBreakpoints.of(context).equals(DESKTOP)
ResponsiveBreakpoints.of(context).largerThan(MOBILE)
ResponsiveBreakpoints.of(context).smallerThan(TABLET)
ResponsiveBreakpoints.of(context).between(MOBILE, TABLET)
...

Customization

You can define your own breakpoint labels and use them in your conditionals.

For example, if you\’re building a Material 3 Navigation Rail and want to expand the menu to full width once there is enough room, you can add a custom EXPAND_SIDE_PANEL breakpoint.

breakpoints: [
  ...
  const Breakpoint(start: 801, end: 1920, name: DESKTOP),
  const Breakpoint(start: 900, end: 900, name: \'EXPAND_SIDE_PANEL\') <- Custom label.
  const Breakpoint(start: 1921, end: double.infinity, name: \'4K\'),
  ...
]

Then, in your code, show the Rail based on the breakpoint condition.

expand: ResponsiveBreakpoints.of(context).largerThan(\’EXPAND_SIDE_PANEL\’)

Responsive Framework Widgets

The ResponsiveFramework includes a few custom widgets that supplement Flutter\’s responsive capabilities. Their usages are showcased in the demo projects.

  • ResponsiveValue

    • ResponsiveVisibility
    • ResponsiveConstraints
  • ResponsiveRowColumn
  • ResponsiveGridView
  • ResponsiveScaledBox
  • MaxWidthBox

Legacy ReadMe (v0.2.0 and below)

ResponsiveWrapper Migration

v1.0.0 Migration Guide

The remainder of the legacy ReadMe is preserved below as the concepts are still useful and used by the new widgets. ResponsiveWrapper has been deprecated and removed.

The Problem

Supporting multiple display sizes often means recreating the same layout multiple times. Under the traditional Bootstrap approach, building responsive UI is time consuming, frustrating and repetitive. Furthermore, getting everything pixel perfect is near impossible and simple edits take hours.

The Solution

Use Responsive Framework to automatically scale your UI.

ResponsiveBreakpoint.autoScale(600);

AutoScale

AutoScale shrinks and expands your layout proportionally, preserving the exact look of your UI.
This eliminates the need to manually adapt layouts to mobile, tablet, and desktop.

ResponsiveBreakpoint.autoScale(600);

Flutter\’s default behavior is resize which Responsive Framework respects. AutoScale is off by default and can be enabled at breakpoints by setting autoScale to true.

Breakpoints

Breakpoints control responsive behavior at different screen sizes.

ResponsiveWrapper(
    child,
    breakpoints: [
        ResponsiveBreakpoint.resize(600, name: MOBILE),
        ResponsiveBreakpoint.autoScale(800, name: TABLET),
        ResponsiveBreakpoint.autoScale(1200, name: DESKTOP),
    ],
)

Breakpoints give you fine-grained control over how your UI displays.

Introductory Concepts

These concepts helps you start using the Responsive Framework and build an responsive app quickly.

Scale vs Resize

Flutter\’s default behavior is to resize your layout when the screen dimensions change. Resizing a layout stretches it in the direction of an unconstrained width or height. Any constrained dimension stays fixed which is why mobile app UIs look tiny on desktop. The following example illustrates the difference between resizing and scaling.

An AppBar widget looks correct on a phone. When viewed on a desktop however, the AppBar is too short and the title looks too small.
Here is what happens under each behavior:

  1. Resizing (default) – the AppBar\’s width is double.infinity so it stretches to fill the available width. The Toolbar height is fixed and stays 56dp.
  2. Scaling – the AppBar\’s width stretches to fill the available width. The height scales proportionally using an aspect ratio automatically calculated from the nearest ResponsiveBreakpoint. As the width increases, the height increases proportionally.

When scaled, the AppBar looks correct on desktop, up to a certain size. Once the screen becomes too wide, the AppBar starts to appear too large. This is where breakpoints come in.

Breakpoint Configuration

To adapt to a wide variety of screen sizes, set breakpoints to control responsive behavior.

ResponsiveWrapper(
    child,
    maxWidth: 1200,
    minWidth: 480,
    defaultScale: true,
    breakpoints: [
        ResponsiveBreakpoint.resize(480, name: MOBILE),
        ResponsiveBreakpoint.autoScale(800, name: TABLET),
        ResponsiveBreakpoint.resize(1000, name: DESKTOP),
        ResponsiveBreakpoint.autoScale(2460, name: \'4K\'),
    ],
)

An arbitrary number of breakpoints can be set. Resizing/scaling behavior can be mixed and matched.

  • below 480: resize on small screens to avoid cramp and overflow errors.
  • 480-800: resize on phones for native widget sizes.
  • 800-1000: scale on tablets to avoid elements appearing too small.
  • 1000+: resize on desktops to use available space.
  • 2460+: scale on extra large 4K displays so text is still legible and widgets are not spaced too far apart.

Additional Resources

Resocoder Tutorial

The wonderful people at Resocoder created a great tutorial video and article walking through the usage of the Responsive Framework at the link below.

View Responsive Framework Tutorial

Project Wiki

No project wiki exists yet unfortunately. That means this is an opportunity for you to create and maintain the wiki for one of the most popular Flutter packages. This package needs your help with documentation!

Please reach out via the contact links below if you are interested.

About

Responsive Framework was created out of a desire for a better way to manage responsiveness. The ability to automatically adapt UI to different sizes opens up a world of possibilities. Here at Codelessly, we\’re building a Flutter app UI and website builder, development tools, and UI templates to increase productivity. If that sounds interesting, you\’ll want to subscribe to updates below ?

Responsive Framework is licensed under Zero-Clause BSD and released as Emailware. If you like this project or it helped you, please subscribe to updates. Although it is not required, you might miss the goodies we share!

Badges ?

Now you can proudly display the time and headache saved by using Responsive Framework with a supporter\’s badge.

[![Flutter Responsive](https://img.*sh**ields.io/badge/flutter-responsive-brightgreen.svg?style=flat-square)](https://github*.*co*m/Codelessly/ResponsiveFramework)
<a href=\"https://github*.*co*m/Codelessly/ResponsiveFramework\">
  <img alt=\"Built Responsive\"
       src=\"https://raw.githubuse*rconte*n*t.com/Codelessly/ResponsiveFramework/master/packages/Built%20Responsive%20Badge.png\"/>
</a>
<a href=\"https://github*.*co*m/Codelessly/ResponsiveFramework\">
  <img alt=\"Built with Responsive Framework\"
       src=\"https://raw.githubus*ercont*e*nt.com/Codelessly/ResponsiveFramework/master/packages/Built%20with%20Responsive%20Badge.png\"/>
</a>

Contributors ❤️

Design:

  • Ray Li

Development:

  • Ray Li
  • Spencer Lindemuth
  • Trefa1998
  • add yourself here by contributing

Sponsor: Codelessly – Flutter App UI and Website Builder

Flutter is a game-changing technology that will revolutionize not just development, but software itself. A big thank you to the Flutter team for building such an amazing platform ?

License

BSD Zero Clause License

Copyright © 2024 Codelessly

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

下载源码

通过命令行克隆项目:

git clone https://github.com/Codelessly/ResponsiveFramework.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 建站资源 ResponsiveFramework https://www.zuozi.net/34921.html

fiction
上一篇: fiction
dev landing page
下一篇: dev landing page
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务