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

套件詳情v0.0.3

flutter_web_scrollbar

適用於 Flutter Web 的可自訂捲軸。

近 30 天下載
52
喜歡數
46
Pub 分數
30

安裝套件

flutter pub add flutter_web_scrollbar

套件介紹

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

專為Flutter web應用設計的可自訂滾動條。它透過提供一個視覺上吸引人且功能完善的滾動指示器,增強了使用者體驗,該指示器可適應web特有的互動方式。滾動條支援自訂樣式、定位和行為調整,讓整合到基於web的Flutter專案變得輕鬆。它與ListView和SingleChildScrollView等標準可滾動組件無縫配合,確保在桌面和平板瀏覽器上的流暢滾動。

適用情境

  • 自定義網頁應用中的滾動條
  • 改善長內容清單的使用者體驗
  • 增強網頁介面的視覺設計
  • 與響應式佈局整合
  • 支援桌面和平板捲動
  • 在不同網路平台創建一致的滾動指示器

主要特色

  • Web優化滾動條設計
  • 完全可自訂的外觀
  • 支援垂直與水平捲動
  • 與 ScrollViews 的輕鬆整合
  • 可設定的軌道與滑塊樣式
  • 在不同螢幕尺寸上的響應式行為

適合對象

  • Flutter 開發者建構 Web 應用程式
  • 尋求精緻捲動 UI 的設計師
  • 需要一致的網頁滾動條行為的專案
  • 包含大量可滾動內容的應用
  • 專注於網頁特定使用者體驗改善的團隊

使用建議

  • 不適用於行動平台
  • 每個可滾動組件都需要顯式設定
  • 僅限網頁平台
  • 可能需要額外的樣式以相容深色模式
  • 對非常大的可滾動清單的效能影響

原始 README

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

flutter_web_scrollbar

A flutter web plugin for adding a customizable scrollbar to your web project. Scroll Bar Web

Usage

To use this plugin add flutter_web_scrollbar as a dependency in your pubspec.yaml file.

Adding the scrollbar to your webpage requires a few mandatory steps:

  1. The content of your page must be the child of a Scrollable Widget (i.e: SingleChildScrollView
  2. The scrollable widget and the FlutterWebScrollbar must be children in a parent Stack
  3. The scrollable widget must be listed first in the Stack
  4. The scrollable widget must have a ScrollController attached to it
  5. The FlutterWebScrollbar must receive a callBack function that accepts a DragUpdateDetails as a parameter.

Example

import 'package:flutter/material.dart';  
import 'package:flutter_web_scrollbar/flutter_web_scrollbar.dart';  
  
class LandingPage extends StatefulWidget {  
  LandingPage({Key key}) : super(key: key);  
  @override  
  State<StatefulWidget> createState() {  
    return _LandingPageState();  
  }  
}  
  
class _LandingPageState extends State<LandingPage> {  
  ScrollController _controller;  
  
  @override  
  void initState() {  
      //Initialize the  scrollController  
      _controller = ScrollController();  
      super.initState();  
  }  
  
  void scrollCallBack(DragUpdateDetails dragUpdate) {  
    setState(() {  
      // Note: 3.5 represents the theoretical height of all my scrollable content. This number will vary for you.  
       _controller.position.moveTo(dragUpdate.globalPosition.dy * 3.5);  
    });  
  }  
  
  @override  
  Widget build(BuildContext context) {  
  
    return Scaffold(  
      backgroundColor: Colors.white,  
      body: Stack(  
        children: [  
          Container(  
            child: SingleChildScrollView(  
              //Assign the controller to my scrollable widget  
              controller: _controller,  
              child: Column(  
                children: [  
                  Container(  
                    height: MediaQuery.of(context).size.height,  
                    width: MediaQuery.of(context).size.width,  
                    color: Colors.black,  
                  ),  
                  Container(  
                    height: MediaQuery.of(context).size.height,  
                    width: MediaQuery.of(context).size.width,  
                    color: Colors.red,  
                  ),  
                  Container(  
                    height: MediaQuery.of(context).size.height,  
                    width: MediaQuery.of(context).size.width,  
                    color: Colors.green,  
                  ),  
                  Container(  
                    height: MediaQuery.of(context).size.height,  
                    width: MediaQuery.of(context).size.width,  
                    color: Colors.blue,  
                  ),  
                ],  
              ),  
            ),  
          ),  
  
  
          FlutterWebScroller(  
            //Pass a reference to the ScrollCallBack function into the scrollbar  
            scrollCallBack,  
  
            //Add optional values  
            scrollBarBackgroundColor: Colors.white,  
            scrollBarWidth: 20.0,  
            dragHandleColor: Colors.red,  
            dragHandleBorderRadius: 2.0,  
            dragHandleHeight: 40.0,  
            dragHandleWidth: 15.0,  
          ),  
        ],  
      ),  
    );  
  }  
}

Things to note about the above code:

  • Inside of our scrollCallBack function, we're updating the ScrollController that is attached to our scrollable widget. It's important to note that in the example, we are using a value of 3.5 to represent the theoretical height of our page content. The theoretical height of your page content may be different. For example, if you have to full height container as your content, you may want to use 2 rather than 3.5. Getting this value as correct as possible plays a big role in how accurate your scrolling will be.
  • Visit the repository here to submit issue reports and request changes
  • If you'd like to help with the upkeep for the plugin, email me at caira102797@gmail.com

Buy Me A Pizza

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。