moon_phase

Flutter plugin that creates moon widgets according to the moon's phase.

Usage

Simple (solid colors)

MoonWidget.simple(
  date: DateTime.now(),
  size: 64,
  moonColor: Colors.amber,
  earthshineColor: Colors.black87,
)

Image (with background)

MoonWidget.image(
  date: DateTime.now(),
  backgroundImageAsset: 'assets/moon.png',
  size: 64,
  shadowRatio: 0.8,
  earthshineColor: Colors.black87,
)

With phase label

MoonWidget.simple(
  date: DateTime.now(),
  size: 64,
  labelPosition: MoonLabelPosition.bottom,
  labelStyle: TextStyle(fontSize: 12),
)

Pass phaseLabels to inject localized strings; missing keys fall back to MoonPhaseNameX.defaultLabels (English).

Parameters

Parameter Description
date DateTime to display
size Widget size
pixelSize Shadow rendering precision (smaller = smoother)
moonColor Light side color (simple mode)
earthshineColor Dark side color
backgroundImageAsset Background image path (image mode)
shadowRatio Shadow radius ratio 0.0~1.0 (image mode)
labelPosition Label placement: top / bottom / left / right. null = no label
phaseLabels Map<MoonPhaseName, String> for i18n; falls back to defaults when a key is missing
labelStyle TextStyle applied to the label
labelSpacing Gap in logical pixels between moon and label (default 4)

Acknowledgements

About