• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Codelessly/ResponsiveFramework: Easily make Flutter apps responsive. Automatical ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

Codelessly/ResponsiveFramework

开源软件地址:

https://github.com/Codelessly/ResponsiveFramework

开源编程语言:

Dart 100.0%

开源软件介绍:

Screenshots

Responsive Framework

Flutter Responsive Pub release GitHub Release Date GitHub issues GitHub top language GitHub code size in bytes Awesome Flutter Libraries.io for GitHub License

Screenshots

Responsiveness made simple

Responsive Framework adapts your UI to different screen sizes automatically. Create your UI once and have it display pixel perfect on mobile, tablet, and desktop!

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.

Screenshots

The Solution

Use Responsive Framework to automatically scale your UI.

ResponsiveBreakpoint.autoScale(600);

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

Pub release

Import this library into your project:

responsive_framework: ^latest_version

Add ResponsiveWrapper.builder to your MaterialApp or CupertinoApp.

import 'package:responsive_framework/responsive_framework.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      builder: (context, child) => ResponsiveWrapper.builder(
          child,
          maxWidth: 1200,
          minWidth: 480,
          defaultScale: true,
          breakpoints: [
            ResponsiveBreakpoint.resize(480, name: MOBILE),
            ResponsiveBreakpoint.autoScale(800, name: TABLET),
            ResponsiveBreakpoint.resize(1000, name: DESKTOP),
          ],
          background: Container(color: Color(0xFFF5F5F5))),
      initialRoute: "/",
    );
  }
}

That's it!

AutoScale

Screenshots

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

Screenshots

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.

Screenshots

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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
umutbozkurt/django-rest-framework-mongoengine: Mongoengine support for Django Re ...发布时间:2022-06-07
下一篇:
wso2/carbon-identity-framework发布时间:2022-06-07
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap