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

slide_switcher 封面
套件詳情v1.1.2

slide_switcher

用於建立具有廣泛自訂選項的切換小部件的套件

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
581
喜歡數
60
Pub 分數
160

安裝套件

flutter pub add slide_switcher

套件介紹

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

一個用於建構可自定義滑動開關元件的 Flutter 套件,提供對外觀與行為的廣泛控制。它讓開發者能夠建立具有平滑動畫、自訂顏色、形狀與尺寸的互動式切換開關。非常適合用於設定面板、主題切換或任何需要視覺開/關狀態變更的 UI。此套件支援所有主要平台,包含行動裝置、網頁與桌面端,確保跨平台體驗的一致性。透過直覺的設定選項,簡化現代、響應式切換介面的實作。

適用情境

  • 主題切換
  • 設定面板
  • 開/關控制
  • 表單輸入
  • 用戶偏好選擇

主要特色

  • 可自定顏色
  • 流暢的動畫
  • 多種尺寸選項
  • 跨平台支援
  • 可設定的軌道和滑塊
  • 狀態持久化

適合對象

  • 開發人員建構設定 UI
  • 需要互動式切換的設計師
  • 具有深色/淺色模式的應用程式
  • 跨平台應用
  • 自定義表單組件

使用建議

  • 需要理解 Flutter 小部件樹
  • 可能需要額外的樣式來處理複雜的佈局
  • 大量實例帶來的效能影響
  • 有限的內建輔助功能
  • 未針對高頻率狀態變更進行優化

原始 README

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

English

Library for creating and customizing sliders

Widget customization variations

Here are some examples of the library's features:

First I suggest you get familiar with what container and sliders are in the library

The library lets you change the style of containers and sliders using the fields in the table below

List and description of the functionality:

Fields Description
children Widgets that placed inside sliders / required
onSelect The function takes an index variable that changes depending on the index of the current slider / required
containerHeight Container height / required
containerWight Container width / required
slidersColors The color of each slider. A single color in the array will fill all sliders / white by default
slidersGradients The gradient of each slider. A single gradient in the array will fill all sliders
containerBorder Container border widget
slidersBorder Slider border widget
containerBorderRadius Container corner rounding radius
containerColor Container fill color / grey by default
indents Indents between the container and sliders (the same on all sides) / 0 by default
direction Defining the direction of the slider swipe / horizontal by default
isAllContainerTap A shadow cast by a box
containerBoxShadow Ability to tap on the current slider and change its index to the opposite (available only for 2 children) / false by default
initialIndex Initial index of the slider, which is rendering for the first time

Creating your own SlideSwitcher

SlideSwitcher is an ordinary widget. In order to create it you have to specify the obligatory parameters: "children" - texts, icons, pictures and any other widgets that will be stored in the sliders; "onSelect" - the function which will be executed during the change of the focused slider; "containerHeight" - container height; "containerWight" - container width. To customize the widget you should use the optional parameters from the table above.

Minimum functionality:
SlideSwitcher(
  children: [
    Text('First'),
    Text('Second'),
  ],
  onSelect: (index) {},
  containerHeight: 40,
  containerWight: 350,
),

To change the state of the screen it is recommended to create a variable storing the index of the current slider and call its setState in the "onSelect" function

int switcherIndex1 = 0;

Column(
  children: [
    SlideSwitcher(
      children: [
        Text('First'),
        Text('Second'),
      ],
      onSelect: (index) => setState(() => switcherIndex1 = index),
      containerHeight: 40,
      containerWight: 350,
    ),
    const SizedBox(height: 20),
    if (switcherIndex1 == 0) ...[
      Container(height: 100, width: 100, color: Colors.red,)
    ]
    else ...[
      Container(height: 100, width: 100, color: Colors.green,)
    ],
  ],
),

List of exceptions for cases that are not supported by the library:

List of exceptions
All widgets from the list of "children" do not fit into the given container size
The "isAllContainerTap" parameter can be "true" only when "children" length is 2

The first error from the table occurs when the smallest side of the container (determined by the direction of the swipe) multiplied by the length of the "children" by half is greater than the largest side of the container. Only occurs when the borders of the container are maximum rounded

NEW

Vertical Switchers.

The direction parameter of this library is responsible for the direction of the switch's movement. Just add direction: Axis.vertical to your widget:

SlideSwitcher(
  children: [
    Text('First'),
    Text('Second'),
  ],
  onSelect: (index) {},
  containerHeight: 350,
  containerWight: 40,
  direction: Axis.vertical
),

Empty Switchers

If you need a switch with two children to determine whether to turn something on or off, then add empty containers to children parameters and parameter isAllContainerTap: true:

SlideSwitcher(
  children: [
    Container(),
    Container(),
  ],
  onSelect: (index) {},
  isAllContainerTap: true,
  containerHeight: 30,
  containerWight: 60,
),

Google form for wishes and suggestions for the package

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。