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

stretchy_header 封面
套件詳情v2.0.0

stretchy_header

此套件允許我們建立一個彈性標題,以在滾動小部件時獲得良好效果。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
236
喜歡數
98
Pub 分數
140

安裝套件

flutter pub add stretchy_header

套件介紹

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

stretchy_header 套件讓開發者能在 Flutter 應用中建立彈性或可拉伸的標題,透過動態視覺效果增強捲動互動。當使用者往下捲動時,標題會拉伸並平滑動畫,提供引人入勝且沉浸式的體驗。對於內容版面豐富且標題視覺在使用者參與度中扮演關鍵角色的應用程式來說,此套件極為理想。該套件支援 Android、iOS、Web、macOS、Windows 與 Linux 等多個平台,確保跨裝置行為一致。

適用情境

  • 建立動畫應用啟動畫面
  • 增強新聞或媒體應用中的滾動效果
  • 設計沉浸式個人檔案或儀表板標題
  • 提升社群媒體介面的使用者參與度
  • 建構視覺上吸引人的入門體驗

主要特色

  • 平滑的彈性拉伸動畫
  • 對自定標題內容的支援
  • 跨平台相容性
  • 與 ListView 或 ScrollController 的輕鬆整合
  • 可設定的拉伸靈敏度與持續時間

適合對象

  • 開發互動式 UI 的開發者
  • 尋求動態標題效果的設計師
  • 內容密集型滾動介面的應用程式
  • 致力於打造精緻使用者體驗的專案

使用建議

  • 可能影響低階裝置的效能
  • 需要仔細調整拉伸參數
  • 不適合用於簡單的靜態標題
  • 超出基本動畫之外的自定義功能有限
  • 最佳搭配輕量級標題內容使用

原始 README

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

Stretchy Header

pub package

This package allows us to create an elastic header, to give a good effect when you scroll down the widget.

Sample 1

Sample 2

Getting started

You should ensure that you add the router as a dependency in your flutter project.

dependencies:
  stretchy_header: "^1.0.8"

You should then run flutter packages upgrade or update your packages in IntelliJ.

Example Project

There is an example project in the example folder. Check it out. Otherwise, keep reading to get up and running.

Usage

Sample 1
import 'package:flutter/material.dart';
import 'package:stretchy_header/stretchy_header.dart';

class SampleListView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: StretchyHeader.listViewBuilder(
        headerData: HeaderData(
          headerHeight: 250,
          header: Image.asset(
            "images/chichen.jpg",
            fit: BoxFit.cover,
          ),
        ),
        itemCount: 15,
        itemBuilder: (context, index) {
          return ListTile(
            title: Text("item $index"),
            onTap: () {
              final snackBar = SnackBar(
                content: Text('item $index tapped'),
              );
              ScaffoldMessenger.of(context).showSnackBar(snackBar);
            },
          );
        },
      ),
    );
  }
}
Sample 2
import 'package:flutter/material.dart';
import 'package:stretchy_header/stretchy_header.dart';

class SampleCustomHeader extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: StretchyHeader.singleChild(
        headerData: HeaderData(
          headerHeight: 200,
          backgroundColor: Colors.black54,
          blurColor: Colors.yellow,
          header: UserAccountsDrawerHeader(
            accountName: Text("Diego"),
            accountEmail: Text("twitter @diegoveloper"),
            currentAccountPicture: CircleAvatar(
              backgroundColor: Colors.red,
              child: Text("DV"),
            ),
            margin: EdgeInsets.zero,
          ),
          overlay: Align(
            alignment: Alignment.bottomRight,
            child: Material(
              color: Colors.transparent,
              child: InkResponse(
                onTap: () {
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(
                      content: Text('onTap'),
                    ),
                  );
                },
                child: Padding(
                  padding: EdgeInsets.all(12),
                  child: Icon(
                    Icons.fullscreen,
                    color: Colors.white,
                  ),
                ),
              ),
            ),
          ),
        ),
        child: Padding(
          padding: const EdgeInsets.all(15),
          child: Text(
            "Hello World!",
            style: TextStyle(fontSize: 45, color: Colors.white),
          ),
        ),
      ),
    );
  }
}
Sample 3
class SampleBottomLabel extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: StretchyHeader.singleChild(
        headerData: HeaderData(
          headerHeight: 250,
          header: Image.asset(
            "images/machu.jpg",
            fit: BoxFit.cover,
          ),
          highlightHeaderAlignment: HighlightHeaderAlignment.bottom,
          highlightHeader: Container(
            width: MediaQuery.of(context).size.width,
            decoration: BoxDecoration(
                gradient: LinearGradient(
                  colors: [
                    Colors.black54,
                    Colors.black54,
                    Colors.black26,
                    Colors.black12,
                    Colors.black12,
                  ],
                  begin: Alignment.bottomCenter,
                  end: Alignment.topCenter,
                )),
            child: Padding(
              padding: const EdgeInsets.all(15),
              child: Text(
                "Machu Picchu",
                style: TextStyle(color: Colors.white, fontSize: 22),
              ),
            ),
          ),
        ),
        child: Padding(
          padding: const EdgeInsets.all(15),
          child: Text(LONG_DESCRIPTION),
        ),
      ),
    );
  }
}
Sample 4
class SampleCenterWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: StretchyHeader.singleChild(
        headerData: HeaderData(
          headerHeight: 250,
          header: Image.asset(
            "images/machu.jpg",
            fit: BoxFit.cover,
          ),
          highlightHeaderAlignment: HighlightHeaderAlignment.center,
          highlightHeader: SizedBox(
            width: MediaQuery.of(context).size.width,
            child: GestureDetector(
              onTap: () {
                print("tap highlightHeader");
              },
              child: CircleAvatar(
                backgroundColor: Colors.red,
                child: Text("M"),
              ),
            ),
          ),
        ),
        child: Padding(
          padding: const EdgeInsets.all(15),
          child: Text(LONG_DESCRIPTION),
        ),
      ),
    );
  }
}

You can follow me on twitter @diegoveloper

所屬分類

原始碼儲存庫

使用此套件的專案