搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.3

argo

用於輕鬆建立響應式應用的組件與工具。可處理顯示性、方向,根據螢幕調整不同版面,並可處理響應式主題的組件。

近 30 天下載
79
喜歡數
24
Pub 分數
60

安裝套件

flutter pub add argo

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Argo 是一個專為 Flutter/Dart 設計的套件,旨在簡化響應式應用的建立。它提供元件與工具,用於管理可見性、螢幕方向以及根據裝置大小的適應性佈局。此套件支援針對不同螢幕環境動態處理主題,確保在各類裝置上提供一致的使用者體驗。僅需透過 `flutter pub add argo` 進行最少設定,開發者即可輕鬆實作響應式介面,無需複雜的條件邏輯。非常適合需要彈性佈局與跨裝置相容性的應用。

適用情境

  • 構建響應式儀表板
  • 建立適應性的行動裝置與平板介面
  • 實現方向感知的佈局
  • 按螢幕尺寸管理主題變體
  • 開發跨平台 Flutter 應用

主要特色

  • 響應式佈局管理
  • 面向方向的元件
  • 動態可見性控制
  • 基於螢幕尺寸的主題設定
  • 輕鬆整合 `pub add`

適合對象

  • 行動和平板應用開發者
  • 專注於響應式佈局的設計師
  • 建構跨裝置應用的團隊
  • 需要自適應UI的Flutter專案
  • 需要動態主題切換的應用程式

使用建議

  • 有限的平台特定文件
  • 當前版本中未明確支援網頁或桌面端
  • 依賴手動設定以滿足進階使用案例
  • 可能需要在不同設備尺寸上進行額外測試

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Argo Package


Widgets and tools for make it easy to create responsive apps for mobile, tablet and web. To handle visibility, orientation and handle diferent layout depend of screen.

style: lint

Special thanks to:

  1. filledstacks
  2. Codelessly
  3. GskinnerTeam

Quick Start

Import this library into your project:

argo: ^latest_version

Add ResponsiveWrapper to your MaterialApp or CupertinoApp.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: ResponsiveWrapper(
        wrapConfig: WrapperConfig(
          globalBreakpoints: ScreenBreakpoints(
            mobile: 321,
            tablet: 650,
            desktop: 1100,
          ),
        ),
        child: Home(),
      ),
    );
  }
}

Or Add ResponsiveWrapper.builder to your MaterialApp or CupertinoApp.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      builder: (context, child) => ResponsiveWrapper.builder(
        wrapConfig: WrapperConfig(
          globalBreakpoints: ScreenBreakpoints(
            mobile: 321,
            tablet: 650,
            desktop: 1100,
          ),
        ),
        builder: (ctx, themeDataRule) => child!,
      ),
      home: Home(),
    );
  }
}

That's it! This widget allows to configurate the WrapperConfig. You can make the manage for Responsive Theme

ScreenBreakpoints

Are the control points that tells ResponsiveWrapper to change the DeviceScreen. This is an upper or lower limit depends on how it is configured compared with Size.width.

Also it serves to do comparisons with the Condition class. SBValue save a value that means Size.width.

Responsive Widgets

ResponsiveVisibility

Widget to show or hide a child depending of the Condition. You can override the globalBreakpoints for localBreakpoints

ResponsiveVisibility.screen(
  conditionScreen: ConditionScreen(
    mobile: true,
    tablet: true,
    desktop: false,
  ),
  child: Container(
    color: Colors.red,
    width: 50,
    height: 50
  ),
),

You can change the condition type and improve the versatility of conditions with ConditionBreakpoint, and make result for VisibleWhen or HiddenWhen.

const List<ConditionBreakpoint<bool>> conditions = [
  ConditionBreakpoint<bool>.equals(
    screenType: DeviceScreen.mobile,
    value: true,
  ),
  ConditionBreakpoint<bool>.smallerThan(
    screenType: DeviceScreen.desktop,
    value: true,
  ),
  ConditionBreakpoint<bool>.equals(
    screenType: DeviceScreen.tablet,
    value: false,
  ),
  ConditionBreakpoint<bool>.largerThan(
    value: true,
    breakpoint: 950,
  ),
];

ResponsiveVisibility.conditions(
  visibleWhen: conditions,
  child: Container(
    color: Colors.red,
    width: 50,
    height: 50
  ),
),

ResponsiveLayoutWidget

This widget show different widget depending of screen type, the condition configuration in ResponsiveWrapper, you can override the globalBreakpoints for localBreakpoints.

ResponsiveLayoutWidget(
  mobile: MobileChild(),
  tablet: TabletChild(),
  desktop: DesktopChild(),
)

In some moments you return and RBuilder, this typedef have the context and ResponsiveInformation. With ResponsiveInformation allows change the basic structure and improve the versatility.

ResponsiveLayoutWidget.builder(
  mobile: (ctx, info) => MobileChild(),
  tablet: (ctx, info) => TabletChild(),
  desktop:(ctx, info) => DesktopChild(),
)

ResponsiveBuilder

This generic widget to handle responsive builder, this widget return the context and ResponsiveInformation. ResponsiveInformation is data class to handle responsive information for the widget. ResponsiveInformation have orientation, localSize, ScreenSize, currentBreakpoints and DeviceScreen.

ResponsiveBuilder(
  builder: (ctx, info) { 
    if(info.localSize.width > 300 && info.deviceScreen.isTablet()){
      return Container(
                color: Colors.red,
                width: 50,
                height: 50
              );
    }else{
      return const SizedBox();
    }
  }
)

OrientationLayoutBuilder

This widget is it create views depending of their orientation. The widget is build with RBuilder, this typedef have the context and ResponsiveInformation.

OrientationLayoutBuilder(
  portrait: (ctx, info) => PortraitChild(),
  landscape: (ctx, info) => LandscapeChild(),
)

TOOLS

valueFromConditionByBreakpoints

You can get single value from ConditionBreakpoint List It's goal is to have more modular conditions compared it with differents breakpoint we can use this to create more complex conditions. And you have three different construtors: ConditionBreakpoint.equals ConditionBreakpoint.largerThan, ConditionBreakpoint.smallerThan

const List<ConditionBreakpoint<bool>> conditions = [
  ConditionBreakpoint<bool>.equals(
    screenType: DeviceScreen.mobile,
    value: true,
  ),
  ConditionBreakpoint<bool>.smallerThan(
    screenType: DeviceScreen.desktop,
    value: true,
  ),
  ConditionBreakpoint<bool>.equals(
    screenType: DeviceScreen.tablet,
    value: false,
  ),
  ConditionBreakpoint<bool>.largerThan(
    value: true,
    breakpoint: 950,
  ),
];

final value = valueFromConditionByBreakpoints<bool>(
  context: context,
  condition: conditions,
  localBreakpoints: screenBreakpoints,
  defaultValue: true,
);

valueFromConditionByBreakpoints

You can get single value from ConditionScreen, It's goal is to have conditional value for the tree screen types mobile, tablet, desktop.

const condition = ConditionScreen(
  mobile: 'Apple',
  tablet: 'Orange',
  desktop: 'Watermelon',
);

final value = valueFromConditionByScreen<String>(
  context: context,
  condition: condition,
  localBreakpoints: screenBreakpoints,
  defaultValue: 'Lemon',
);

ResponsiveContext Extension

You can get from the context info for make it easy the responsive apps

  context.widthPx = Returns same as MediaQuery.of(context).size.width
  context.heightPx = Returns same as MediaQuery.of(context).size.height
  context.theme = Getting Theme
  context.widthPct(10) = Returns percent (1-100) of screen width in pixels
  ...

Responsive Theme

Data class to handle the theme responsive information, this class may be used from ResponsiveWrapper It's used from ResponsiveWrapper to get the value for the currentBreakpoints Use differents conditions to store the themes.

The advantage is that you can create all the classes with IThemeDataRule for the configurations the app need.

It basic use:

ResponsiveTheme.screen(
   conditionScreen: ConditionScreen(
     mobile: MyThemesApp(),
     tablet: MyThemesTablet(),
     desktop: MyThemesWeb(),
   ),
 )

This is an example of a configuration:



class MyThemesApp with IThemeDataRule {
  @override
  ThemeData getThemeByRule({ThemeRule rule = ThemeRule.light}) {
    switch (rule) {
      case ThemeRule.light:
        return lightTheme;
      case ThemeRule.dark:
        return darkTheme;
      case ThemeRule.custom:
        return darkerTheme;
      default:
        return lightTheme;
    }
  }
}

// This is a themeData for LightTheme is a normal object
final ThemeData lightTheme = ThemeData(
    primaryColor: Colors.blueGrey,
    brightness: Brightness.light,
    textTheme: TextTheme(
      headline1: headline1.copyWith(fontSize: 26),
      headline2: headline2.copyWith(fontSize: 18),
    ),
  );


For more information and understand the Theme Responsive check the Documentation and the Example.

Examples
  1. ArgoExample: Simple example of use the argo library
  2. ThemingExample: Basic use for the ResponsiveTheming
  3. BaseLandingPage: Basic landing page with argo

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 💙

Flutter

Maintainers

You are welcome to contribute :3

TODO

  • Improve the test
  • Improve de readme
  • Add globalLogs(inprogress)

License

MIT License
Copyright (c) 2021 James Cardona

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。