パッケージ、リポジトリ、アプリカテゴリを検索

flutter_inset_shadow のカバー
パッケージ詳細v2.0.3

flutter_inset_shadow

このパッケージは、BoxShadow と BoxDecoration を拡張して inset プロパティをサポートしています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
2.2万
いいね数
38
Pub ポイント
150

パッケージをインストール

flutter pub add flutter_inset_shadow

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

flutter_inset_shadow パッケージは、BoxShadow および BoxDecoration クラスに inset プロパティのサポートを追加することで、ウィジェットの境界内に影を表示できるように拡張します。これは、内側の光沢や段差のあるデザインを作成する際に特に役立ちます。このパッケージは既存の Flutter UI コンポーネントとシームレスに統合され、Android、iOS、Web、macOS、Windows、Linux などの主要プラットフォームをすべてサポートしています。カスタム描画や複雑な回避策なしに、繊細でモダンな UI 要素の実装を簡単にできます。

用途

  • カードやコンテナのインナー阴影を作成する
  • 埋め込みまたは沈み込んだUI要素の設計
  • モダンなインターフェースに繊細な奥行き効果を追加する
  • 発光またはインセットボーダー効果の実装
  • 内部の影による視覚的階層の強化

主な機能

  • BoxShadow拡張を介してインセットシャドウをサポート
  • 内側の影のレンダリング用に BoxDecoration を拡張します
  • クロスプラットフォーム互換性
  • 既存のウィジェットとの簡単な統合
  • 最小限のボイラープレートが必要

適している対象

  • 高度なシャドウ効果を求めるUIデザイナー
  • モダンでフラットデザインのアプリを開発する開発者
  • 外部ライブラリに頼らずに微細な奥行きを必要とするプロジェクト
  • マルチプラットフォームアプリ用にFlutterを使用するチーム

注意事項

  • 複雑なレイアウトでのパフォーマンスに影響する可能性があります
  • 基本的なシャドウスタイルに制限
  • 非常に動的なまたはアニメーションされた影には適していません
  • さまざまな画面密度での慎重なテストが必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Flutter Inset Shadow

Flutter currently does not support the inset property for shadows. This type of shadow is for example used in Neumorphism.

This package extends BoxShadow and BoxDecoration to support the inset property.

[!IMPORTANT]

What happened to flutter_inset_box_shadow?

Previously, this package was called flutter_inset_box_shadow.

Unfortunately, I've lost access to the verified publisher, allowing me to publish updates to the package.

So I decided to publish the package under a new name.

For more information, you can read https://github.com/chitochi/flutter_inset_shadow/issues/7. 😄

Features

  • All properties of BoxShadow are supported.
  • If the property of a BoxShadow changes during a transition, we first make the old shadow disappear before making the new one appear.

Example

A simple neumorphic container

import 'package:flutter/material.dart' hide BoxDecoration, BoxShadow;
import 'package:flutter_inset_shadow/flutter_inset_shadow.dart';

void main() {
  runApp(const ExampleApp());
}

const primaryColor = Color(0xFFE0E0E0);

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Example',
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        backgroundColor: primaryColor,
        body: Center(
          child: Container(
            width: 150,
            height: 150,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(50),
              color: primaryColor,
              boxShadow: const [
                BoxShadow(
                  offset: Offset(-20, -20),
                  blurRadius: 60,
                  color: Colors.white,
                  inset: true,
                ),
                BoxShadow(
                  offset: Offset(20, 20),
                  blurRadius: 60,
                  color: Color(0xFFBEBEBE),
                  inset: true,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Usage

First, add the package:

flutter pub add flutter_inset_shadow

Then, import it as follows:

import 'package:flutter/material.dart' hide BoxDecoration, BoxShadow;
import 'package:flutter_inset_shadow/flutter_inset_shadow.dart';

It is necessary to hide BoxDecoration and BoxShadow because this library replaces them.

BoxShadow now has a boolean inset property, which is set to false by default.

return Container(
  decoration: BoxDecoration(
    boxShadow: [
      BoxShadow(
        blurRadius: 5,
        color: Colors.red,
      ),
      BoxShadow(
        offset: Offset(1, 2),
        blurRadius: 5,
        spreadRadius: 2,
        color: Colors.green,
        inset: true,
      ),
    ],
  ),
);

How does it work?

The algorithm used is the same as that of Blink, the Chromium rendering engine.

The idea is that we draw a rectangle hollowed out by another rounded rectangle inside, then we blur this hollowed rectangle.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト