-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ResizableDivider config class * Move divider config into new model * Fix alignment of line within space * Add indent and endIndent back to DividerPainter * Clean up helper methods * Rename height to size * Add ResizableDivider tests
- Loading branch information
Showing
8 changed files
with
159 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class ResizableDivider { | ||
const ResizableDivider({ | ||
this.thickness = 1.0, | ||
this.size = 2.0, | ||
this.color, | ||
this.indent, | ||
this.endIndent, | ||
}) : assert(size >= thickness, '[size] must be >= [thickness].'), | ||
assert(thickness > 0, '[thickness] must be > 0.'); | ||
|
||
/// The thickness of the line drawn within the divider. | ||
/// | ||
/// Defaults to 1.0. | ||
final double thickness; | ||
|
||
/// The divider's size (height/width) extent. | ||
/// The divider line will be drawn in the center of this space. | ||
/// | ||
/// Defaults to 2.0. | ||
final double size; | ||
|
||
/// The color of the dividers between children. | ||
/// | ||
/// Defaults to [ThemeData.dividerColor]. | ||
final Color? color; | ||
|
||
/// The amount of empty space to the leading edge of the divider. | ||
/// | ||
/// For dividers running from top-to-bottom, this adds empty space at the top. | ||
/// For dividers running from left-to-right, this adds empty space to the left. | ||
final double? indent; | ||
|
||
/// The amount of empty space to the trailing edge of the divider. | ||
/// | ||
/// For dividers running from top-to-bottom, this adds empty space at the bottom. | ||
/// For dividers running from left-to-right, this adds empty space to the right. | ||
final double? endIndent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'package:flutter_resizable_container/flutter_resizable_container.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group(ResizableDivider, () { | ||
group('thickness', () { | ||
test('must be greater than 0', () { | ||
expect(() => ResizableDivider(thickness: 0), throwsAssertionError); | ||
}); | ||
|
||
test('accepts greater than 0', () { | ||
expect( | ||
() => const ResizableDivider(thickness: 1), | ||
isNot(throwsAssertionError), | ||
); | ||
}); | ||
}); | ||
|
||
group('size', () { | ||
test('throws if less than thickness', () { | ||
expect( | ||
() => ResizableDivider(thickness: 1, size: 0.5), | ||
throwsAssertionError, | ||
); | ||
}); | ||
|
||
test('does not throw if the same as thickness', () { | ||
expect( | ||
() => const ResizableDivider(thickness: 1, size: 1), | ||
isNot(throwsAssertionError), | ||
); | ||
}); | ||
|
||
test('does not throw if greater than thickness', () { | ||
expect( | ||
() => const ResizableDivider(thickness: 1, size: 2), | ||
isNot(throwsAssertionError), | ||
); | ||
}); | ||
}); | ||
}); | ||
} |