Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ A beautiful circle color picker for flutter. [Online Demo](https://itome.github.
/// This callback called with latest color that user selected.
final ValueChanged<Color>? onEnded;

/// Called when the center circle is tapped.
///
/// This callback called with latest color that user selected.
final ValueChanged<Color>? onTap;

/// An object to controll picker color dynamically.
///
/// Provide initialColor if needed.
Expand Down
39 changes: 26 additions & 13 deletions lib/flutter_circle_color_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CircleColorPicker extends StatefulWidget {
Key? key,
this.onChanged,
this.onEnded,
this.onTap,
this.size = const Size(280, 280),
this.strokeWidth = 2,
this.thumbSize = 32,
Expand All @@ -46,6 +47,11 @@ class CircleColorPicker extends StatefulWidget {
/// This callback called with latest color that user selected.
final ValueChanged<Color>? onEnded;

/// Called when the center circle is tapped.
///
/// This callback called with latest color that user selected.
final ValueChanged<Color>? onTap;

/// An object to controll picker color dynamically.
///
/// Provide initialColor if needed.
Expand Down Expand Up @@ -138,21 +144,28 @@ class _CircleColorPickerState extends State<CircleColorPicker>
style: widget.textStyle,
),
const SizedBox(height: 16),
Container(
width: 64,
height: 64,
decoration: BoxDecoration(
color: _color,
shape: BoxShape.circle,
border: Border.all(
width: 3,
color: HSLColor.fromColor(_color)
.withLightness(
_lightnessController.value * 4 / 5,
)
.toColor(),
Material(
child: Ink(
child: InkWell(
customBorder: CircleBorder(),
onTap: (widget.onTap != null)
? () => widget.onTap?.call(_color)
: null),
width: 64,
height: 64,
decoration: BoxDecoration(
color: _color,
shape: BoxShape.circle,
border: Border.all(
width: 3,
color: HSLColor.fromColor(_color)
.withLightness(
_lightnessController.value * 4 / 5,
)
.toColor()),
),
),
shape: const CircleBorder(),
),
const SizedBox(height: 16),
_LightnessSlider(
Expand Down