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

dynamic_background 封面
套件詳情v0.6.0

dynamic_background

允許開發者為其 Flutter 應用建立動畫背景。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
512
喜歡數
52
Pub 分數
160

安裝套件

flutter pub add dynamic_background

套件介紹

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

dynamic_background 包讓 Flutter 開發者能夠輕鬆在其應用程式中實作流暢、動畫背景。它支援多種視覺效果,包括漸層動畫、著色器基礎的視覺效果,以及可自訂的運動模式。專為跨平台使用設計,可在 Android、iOS、Web、macOS、Windows 與 Linux 上順暢運作。該套件可透過簡單的 pub add 命令輕鬆整合至現有的 Flutter 項目,並提供彈性 API,用於細調動畫速度、方向與色彩過渡。非常適合在不帶來沉重效能負擔的情況下提升應用美學。

適用情境

  • 建立沉浸式啟動畫面
  • 增強入門體驗
  • 為儀表板增添視覺魅力
  • 透過動態效果提升使用者參與度
  • 設計主題化應用介面

主要特色

  • 動畫漸層背景
  • 基於著色器的視覺效果
  • 可自定的動畫速度和方向
  • 跨平台相容性
  • 輕量且高效
  • 透過 pub.dev 實現輕鬆整合

適合對象

  • 尋求動態視覺效果的UI設計師
  • 開發人員建構吸引人的引導流程
  • 需要現代動畫背景的應用程式
  • 針對多個平台的專案
  • 創意或生活風格應用開發

使用建議

  • 可能影響低階裝置的效能
  • 需要仔細調整才能獲得最佳幀率
  • 超出所提供參數的自定義有限
  • 最佳搭配最少的前景內容使用
  • 不建議用於靜態或極簡設計

原始 README

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

Dynamic Background

A blue and black logo for Dynamic BG

Dynamic Background is a Flutter package that transforms your app's background into a captivating canvas of animated elements. Whether you prefer sleek stripes, mesmerizing gradients, or playful shapes, Dynamic Background provides an easy-to-use solution to breathe life into your UI. This versatile package offers customizable options to suit any design aesthetic, effortlessly elevating your app's visual appeal. Take your Flutter development to the next level with Dynamic Background – where stunning visuals meet effortless implementation for an immersive and visually striking app interface.

Four examples of different animated backgrounds. Four examples of different animated backgrounds. Four examples of different animated backgrounds.

Installation

In the pubspec.yaml of your project, add the following dependency:

dependencies:
  dynamic_background: ^0.5.0

Import it to each file you use it in:

import 'package:dynamic_background/dynamic_background.dart';

Usage

Example 1 - Simple circles scrolling

This example shows how to set up an animated background that shows blue circles scrolling from right to left on a pale blue background.

Note: The colors being used are provided with this package.

DynamicBg(
  painterData: ScrollerPainterData(
    shape: ScrollerShape.circles,
    backgroundColor: ColorSchemes.gentleBlueBg,
    color: ColorSchemes.gentleBlueFg,
    shapeOffset: ScrollerShapeOffset.shiftAndMesh,
  ),
  child: yourPageHere(),
),
Example 2 - Simple blue fader

This example shows how to set up an animated background that fades gently and randomly between different shades of blue.

Note: The colors being used are provided with this package.

DynamicBg(
  painterData: FaderPainterData(
    behavior: FaderBehavior.random,
    colors: ColorSchemes.gentleBlue,
  ),
  child: yourPageHere(),
),
Example 3 - Simple wave

This example shows how to set up an animated background with a blue, sine wave line in the middle of the screen.

Note: The colors being used are provided with this package.

DynamicBg(
  duration: const Duration(seconds: 5),
  painterData: WavePainterData(
    waves: [
      Wave(
        direction: WaveDirection.left2Right,
        amplitude: 50.0,
        offset: 0.5,
        color: Colors.transparent,
        lineColor: ColorSchemes.gentleBlueBg,
        lineThickness: 3.0,
      ),
    ],
  ),
  child: yourPageHere(),
),
Example 4 - Simple Lava Lamp

This example shows how to set up an animated background with moving circles to have a lava lamp effect.

Note: The colors being used are provided with this package.

DynamicBg(
  duration: const Duration(seconds: 35),
  painterData: LavaPainterData(
    width: 250.0,
    widthTolerance: 75.0,
    growAndShrink: true,
    growthRate: 10.0,
    growthRateTolerance: 5.0,
    blurLevel: 25.0,
    numBlobs: 5,
    backgroundColor: ColorSchemes.gentleWhiteBg,
    colors: [
      ColorSchemes.vibrantOrangeBg,
      ColorSchemes.vibrantOrangeFg,
      ColorSchemes.vibrantYellowBg,
      ColorSchemes.vibrantYellowFg,
    ],
    allSameColor: false,
    fadeBetweenColors: true,
    changeColorsTogether: false,
    speed: 20.0,
    speedTolerance: 5.0,
  ),
  child: yourPageHere(),
),
Example 5 - Prebuilt backgrounds

This example shows how to use prebuilt backgrounds.

This example also show the use of a custom duration. The prebuilt backgrounds give suggestions in their comments on how best to use them; this includes duration and platform brightness.

DynamicBg(
  duration: const Duration(seconds: 45),
  painterData: PrebuiltPainters.chocolate,
  child: yourPageHere(),
),
Example 6 - Modify prebuilt backgrounds

This example shows how to modify prebuilt backgrounds to best fit your needs.

The copyWith method can also be used on your own custom backgrounds.

DynamicBg(
  duration: const Duration(seconds: 45),
  painterData: PrebuiltPainters.chocolate.copyWith(
    backgroundColor: ColorSchemes.gentleYellowBg,
  ),
  child: yourPageHere(),
),
Example 7 - Stack backgrounds

This example shows how to stack backgrounds for interesting new effects.

DynamicBg(
  painterData: ScrollerPainterData(
    direction: ScrollDirection.left2Right,
    backgroundColor: ColorSchemes.gentleWhiteBg,
    color: ColorSchemes.gentleBlackFg,
    shapeOffset: ScrollerShapeOffset.shiftAndMesh,
  ),
  child: DynamicBg(
    duration: const Duration(seconds: 45),
    painterData: ScrollerPainterData(
      backgroundColor: Colors.transparent,
      color: ColorSchemes.vibrantBlackFg,
      shapeWidth: 28.0,
      spaceBetweenShapes: 55.0,
      shapeOffset: ScrollerShapeOffset.shiftAndMesh,
    ),
    child: yourPageHere(),
  ),
),
Example 8 - Backgrounds for smaller widgets

This example shows that you can apply dynamic backgrounds to widgets rather than the entire screen. Here is a button with an animated background.

final double buttonWidth = 500.0;
final double buttonHeight = 65.0;
final BorderRadius buttonRadius = BorderRadius.circular(5.0);

ClipRRect(
  borderRadius: buttonRadius,
  child: DynamicBg(
    width: buttonWidth,
    height: buttonHeight,
    painterData: ScrollerPainterData(
      direction: ScrollDirection.right2Left,
      shape: ScrollerShape.stripesDiagonalForward,
      backgroundColor: Color.fromARGB(255, 214, 232, 185),
      color: Color.fromARGB(255, 198, 225, 151),
      shapeWidth: 24.0,
      spaceBetweenShapes: 24.0,
      fadeEdges: false,
    ),
    child: Material(
      color: Colors.transparent,
      child: InkWell(
        onTap: () {
          print('Button pressed');
        },
        borderRadius: buttonRadius,
        child: Center(
          child: Text(
            'Save',
            style: TextStyle(
              color: Colors.white,
              fontSize: 25.0,
              fontWeight: FontWeight.w800,
            ),
          ),
        ),
      ),
    ),
  ),
),

If you found this helpful, please consider donating. Thanks!

buy me a coffee      paypal      venmo



所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。