패키지, 저장소 및 앱 카테고리 검색

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 디자이너
  • 현대적인 플랫 디자인 앱을 개발하는 개발자
  • 외부 라이브러리 없이 미묘한 깊이를 필요로 하는 프로젝트
  • 다중 플랫폼 앱을 위한 플러터 사용 팀

고려 사항

  • 복잡한 레이아웃에서 성능에 영향을 미칠 수 있습니다
  • 기본 그림자 스타일링에 제한됨
  • 매우 동적인 또는 애니메이션된 그림자에 적합하지 않습니다
  • 다양한 화면 밀도에서 신중한 테스트가 필요합니다

원본 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.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트