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

black_hole_flutter 표지
패키지 상세v2.0.0

black_hole_flutter

모든 플러터 유틸리티 함수를 포함하는 패키지로, 확장 함수 및 자주 사용되는 위젯을 포함

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.7만
좋아요
70
Pub 점수
160

패키지 설치

flutter pub add black_hole_flutter

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Black_Hole_Flutter는 자주 사용되는 확장 함수와 재사용 가능한 위젯을 하나의 간편한 가져오기 솔루션으로 통합하는 포괄적인 유틸리티 패키지입니다. 개발을 간소화하기 위해 설계되었으며, 안드로이드, iOS, 웹, 맥OS, 윈도우, 리눅스 등 여러 플랫폼에서 시간 절약 도구를 제공합니다. 이 패키지는 자주 필요한 기능의 중앙 허브 역할을 하여 봐일러플레이트 코드를 줄이고 Flutter 프로젝트의 일관성을 촉진합니다. 효율성과 빠른 프로토타이핑을 원하는 개발자에게 적합합니다.

사용 사례

  • 빠른 UI 개발
  • 프로젝트 간 코드 재사용
  • 일반적인 작업 간소화
  • 크로스 플랫폼 유틸리티
  • Prototyping
  • 반복 코드 줄이기

주요 기능

  • 통합 유틸리티 확장
  • 재사용 가능한 위젯
  • 다중 플랫폼 지원
  • 최소 설정
  • 일관된 코딩 스타일
  • 확장 가능한 설계

적합한 대상

  • 초보자에서 고급까지의 Flutter 개발자
  • 대규모 앱 개발
  • 코드 일관성을 우선시하는 팀
  • 빠른 반복이 필요한 프로젝트
  • 최소한의 종속성 원하는 개발자

고려 사항

  • 사용되지 않은 유틸리티가 포함될 수 있습니다
  • 의존성 블로트 가능성
  • 기능별로 사용자 정의가 제한됨
  • 매우 전문적인 요구 사항에는 적합하지 않습니다
  • 포함된 함수에 대한 신중한 검토가 필요합니다
  • 프로젝트 범위가 포함된 도구와 일치할 때 가장 효과적으로 사용됩니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

🛠 A package absorbing all Flutter utility functions, including extension functions and commonly used widgets.

📄 Bottom Sheet

Show modal bottom sheets using: context.showModalBottomSheet().

FancyBottomSheet demo

Also, this package adds a custom FancyBottomSheet with a drag indicator at the top. You can create one using context.showFancyModalBottomSheet().

🏗 BuildContext

In Flutter, you often see the pattern <Class>.of(context) (e.g., Theme.of(context)). This package adds extension getters on BuildContext for those classes so you can just say:

Extension Shortcut for
context.colorScheme ColorScheme.of(context)
context.defaultTextStyle DefaultTextStyle.of(context)
context.directionality Directionality.of(context)
context.form Form.of(context)
context.locale Localizations.localeOf(context)
context.materialLocalizations MaterialLocalizations.of(context)
context.mediaQuery MediaQuery.of(context)
context.overlay Overlay.of(context)
context.pageStorage PageStorage.of(context)
context.scaffold Scaffold.of(context)
context.scaffoldOrNull Scaffold.of(context, nullOk: true)
context.textTheme TextTheme.of(context)
context.theme Theme.of(context)

🎨 Colors

Handy extensions on Brightness:

Extension Explanation
brightness.isDark ≙ brightness == Brightness.dark
brightness.isLight ≙ brightness == Brightness.light
brightness.opposite opposite Brightness
brightness.color Color representing this brightness, i.e.:
· Colors.white for Brightness.light
· Colors.black for Brightness.dark
brightness.contrastColor opposite of brightness.color (above)

isDark, isLight, and contrastColor can also be used on ThemeData directly.

Handy extensions on Color:

Extension Explanation
color.estimatedBrightness estimated Brightness based on color's luminance
color.isOpaque if opacity is 1.0
color.alphaBlendOn(Color background) resulting Color when drawing color on top of background
color.withAdditionalOpacity(double opacity) applies opacity by multiplying it to the existing opacity
color.withAdditionalAlpha(int alpha) like above, but with an integer alpha
color.hsl ≙ HSLColor.fromColor(color)
color.hsv ≙ HSVColor.fromColor(color)

And if you can't decide on a color, just use random.nextColor(), random.nextColorHsl() or random.nextColorHsv()!

Convert between alpha and opacity with int.alphaToOpacity and double.opacityToAlpha.

🌈 Material Design colors

Material Design specifies different opacities of white and black colors to use for text of different emphases on colored backgrounds. You can now use the highEmphasisOnColor, mediumEmphasisOnColor and disabledOnColor extension getters on Color to make your text legible! The raw opacity values are also available as MaterialColors.highEmphasisTextAlpha, MaterialColors.mediumEmphasisTextAlpha, and MaterialColors.disabledTextAlpha.

🧭 Navigation

Access your navigation-related information via extension methods:

Extension Shortcut for
context.navigator Navigator.of(context)
context.rootNavigator Navigator.of(this, rootNavigator: true)
context.modalRoute ModalRoute.of(context)

Push a new route and pop all previous routes (e.g., when signing out the user):

navigator.pushAndRemoveAll(/* new route */);
// Or using a named route:
navigator.pushNamedAndRemoveAll(/* route name */);

Log navigation events to the console:

MaterialApp(
  navigatorObservers: [LoggingNavigatorObserver()],
  // ...
)
// Prints:
// Navigator: didPush /dashboard → /articles/12345
// Navigator: didPop /dashboard ← /articles/12345

Note: This uses the name of routes, so it only works with named routes.

📱 Widgets

🔳 Buttons

Did you ever want to show a progress indicator inside a button? Or were annoyed to conditionally set a Button's onPressed to disable it? Fear no more — black_hole_flutter has got you covered!

Button demo

This screenshot only shows an excerpt of all available button types and variants.

In FancyFab (a FloatingActionButton), FancyTextButton, FancyOutlinedButton, FancyElevatedButton, FancyFilledButton, and FancyIconButton, we introduce some new parameters:

🥙 FillOrWrap
FillOrWrap demo

A layout with two different behaviors:

  • By default, all children are positioned next to each other with equal widths. This is comparable to a Row with all children wrapped in Expanded.
  • If the children are too wide to fit in a single line, or one child would become smaller than its reported minimum width, the children get positioned below each other ("wrapped"). This is similar to a Column with MainAxisSize.min.
🎯 LeftCenterRight

A layout taking optional left, center, and right children. It will try to keep center in the center of itself, even if only one of left and right is set, or they have different widths.

🟢 Circle

A circle with optional diameter, background color, padding, and child.

🖼 RenderObject

When writing a custom layout, you might find this extension on ContainerRenderObjectMixin useful:

Extension Explanation
containerRenderObjectMixin.children Returns all children using firstChild and childAfter

↕ Size

Extension Explanation
size.diagonal length of the diagonal of a rectangle with this Size
size.squaredDiagonal ≙ size.diagonal * size.diagonal
size.coerceAtLeast(Size minimum) Ensures size is not smaller than minimum in any axis
size.coerceAtMost(Size maximum) Ensures size is not larger than minimum in any axis

카테고리

의존성

의존성 목록 3 개

소스 저장소

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