Skip to content

Commit 5e2f3bf

Browse files
authored
Merge pull request #4 from felixgabler/small_lines
Make it possible to specify how many small lines should be between big lines
2 parents 8dc834f + 18373e6 commit 5e2f3bf

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,15 @@ use `FlutterSliderHatchMark` class which has following properties:
503503
2. `bigLine`: The widget of big lines in hatch mark
504504
3. `smallLine`: The widget of small lines in hatch mark
505505
4. `linesAlignment`: the direct of lines, `right` or `left` which works as `top` or `bottom` on horizontal slider
506-
5. `density`: The amount of lines per percent. 1 is default. any number less or more than 1 will decrease and increase lines respectively
507-
6. `displayLines`: to display lines. by default is `false` for the sake of optimization
506+
5. `density`: The number of lines per percent. 1 is default. any number less or more than 1 will decrease and increase lines respectively
507+
6. `smallDensity`: The number of small lines between any two big lines. 4 is default. any number less or more than 4 will decrease and increase lines respectively.
508+
7. `displayLines`: to display lines. by default is `false` for the sake of optimization
508509

509-
7. `labels`: If you want to display some label or text at certain percent in your hatch mark, you can use `labels`
510-
8. `labelBox`: The widget of label box, however, you can define a widget for each label and have it's own style
511-
9. `labelsDistanceFromTrackBar`: The distance of labels from slider. can be negative
510+
8. `labels`: If you want to display some label or text at certain percent in your hatch mark, you can use `labels`
511+
9. `labelBox`: The widget of label box, however, you can define a widget for each label and have it's own style
512+
10. `labelsDistanceFromTrackBar`: The distance of labels from slider. can be negative
512513

513-
10. `disabled`: to disabled the whole hatchmark ( hide )
514+
11. `disabled`: to disabled the whole hatchmark ( hide )
514515

515516
**labels alignment is center**
516517

lib/another_xlider.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ class _FlutterSliderState extends State<FlutterSlider>
466466
FlutterSliderHatchMark hatchMark = FlutterSliderHatchMark();
467467
hatchMark.disabled = widget.hatchMark!.disabled;
468468
hatchMark.density = widget.hatchMark!.density;
469+
hatchMark.smallDensity = widget.hatchMark!.smallDensity;
469470
hatchMark.linesDistanceFromTrackBar =
470471
widget.hatchMark!.linesDistanceFromTrackBar ?? 0;
471472
hatchMark.labelsDistanceFromTrackBar =
@@ -518,7 +519,7 @@ class _FlutterSliderState extends State<FlutterSlider>
518519
for (int p = 0; p <= percent; p++) {
519520
FlutterSliderSizedBox? barLineBox = hatchMark.smallLine;
520521

521-
if (p % 5 - 1 == -1) {
522+
if (p % (hatchMark.smallDensity + 1) == 0) {
522523
barLineBox = hatchMark.bigLine;
523524
}
524525

@@ -2606,13 +2607,16 @@ class FlutterSliderHatchMark {
26062607
List<FlutterSliderHatchMarkLabel>? labels;
26072608
FlutterSliderSizedBox? smallLine;
26082609
FlutterSliderSizedBox? bigLine;
2610+
/// How many small lines to display between two big lines
2611+
int smallDensity;
26092612
FlutterSliderSizedBox? labelBox;
26102613
FlutterSliderHatchMarkAlignment linesAlignment;
26112614
bool? displayLines;
26122615

26132616
FlutterSliderHatchMark(
26142617
{this.disabled = false,
26152618
this.density = 1,
2619+
this.smallDensity = 4,
26162620
this.linesDistanceFromTrackBar,
26172621
this.labelsDistanceFromTrackBar,
26182622
this.labels,
@@ -2621,7 +2625,8 @@ class FlutterSliderHatchMark {
26212625
this.linesAlignment = FlutterSliderHatchMarkAlignment.right,
26222626
this.labelBox,
26232627
this.displayLines})
2624-
: assert(density > 0 && density <= 2);
2628+
: assert(density > 0 && density <= 2),
2629+
assert(smallDensity >= 0);
26252630

26262631
@override
26272632
String toString() {

0 commit comments

Comments
 (0)