Curtains class
📜 Curtains
Wraps a scrollable child with scrim decorations while not at the start or end, alluding to unrevealed content. |
---|
Choose animated Curtains or Curtains.instant to provide custom
Decorations, or select Curtains.elevated for a simpler syntax
with double
elevation instead of individual Decoration
s.
With non-negative Sensitivity, the scrims of this 📜 Curtains
will change state before the scrollable reaches a min/max extent.
sensitivity.start
defines startCurtain tolerance to min extent.sensitivity.end
defines endCurtain tolerance to max extent.
Before any scrolling occurs endCurtain initializes visible, even if
the 📜 Curtains
wrap a scrollable not long enough to scroll.
- If this does not fit the situation, consider endInitVisible.
- Also available is startInitVisible. Defaults
false
.
{@tool snippet}
Elevated 📜 Curtains
Provide a scrolling child.
Specify scrim shadows by double
elevation property.
- Default
elevation
is9.0
- color may be overridden, but the Material-defined opacity is maintained
Initialize scrollDirection to match scrollable child:
- Axis.vertical (default) or Axis.horizontal
✝ See: Elevation.asBoxShadows
final curtains = Curtains.elevated(
child: ListView(
children: List.generate(
25,
(i) => ListTile(title: Text('ListTile #: ${i+1}')),
),
),
elevation: 24.0 // optional, defaults to `9.0`
// Optional color; will maintain Material elevation opacities.✝
color: Colors.red
);
{@end-tool}
{@tool snippet}
Instant 📜 Curtains
All the ease of positioning provided by the Curtains.elevated constructor,
but swap out the bespoke elevation double
and provide one or both of
full-fat Decorations startCurtain and endCurtain.
Leaving a Curtain
parameter null
will render an empty decoration
in that position.
Optionally define Curtains.spread for "girthier" scrims,
allowing, for example, BoxDecoration.gradient passes.
final curtains = Curtains.instant(
/// 🕴 Named constructor 📜 [Curtains.elevated] employs
/// `Elevation.asBoxDecoration` to render its decorations; but feel free
/// to use these static methods, too, opting for 👥 [package:shadows].
startCurtain: const BoxDecoration(. . .) // Elevation.asBoxDecoration(12.0), // 🕴
endCurtain: BoxDecoration(boxShadow: Elevation.asBoxShadows(12.0)), // 🕴
child: ListView(
children: List.generate(
25,
(i) => ListTile(title: Text('ListTile #${i+1}')),
),
),
);
{@end-tool}
{@tool snippet}
Animated 📜 Curtains
All the ease of positioning provided by the Curtains.elevated constructor,
and the customization support of Curtains.instant, but animations support
means these 📜 Curtains
intrinsically morph with a duration and/or curve;
or leave it up to the defaults.
final curtains = Curtains(
startCurtain: buildCurtain(),
endCurtain: buildCurtain(isStart: false),
// Provide `spread` to [Curtains] for decoration support beyond [BoxShadow]s.
// (Gives "girth" to individual [_Curtain] containers; otherwise `0`.)
spread: 50.0,
// `start` appears once scrolled `350` px beyond start
// `end` appears once scrolled `175` px beyond end
sensitivity: const Sensitivity(350.0, 175.0),
// 📜 Curtains are animated:
duration: const Duration(milliseconds: 600),
curve: Curves.fastOutSlowIn,
// ↔ If wrapping a horizontal scrollable, initialize here, too:
scrollDirection: Axis.horizontal, // ↔
child: ListView(
scrollDirection: Axis.horizontal, // ↔
itemExtent: 100.0,
children: List.generate(
25,
(i) => ListTile(title: Text('ListTile #${i+1}')),
),
),
);
BoxDecoration buildCurtain({bool isStart = true}) => BoxDecoration(
gradient: LinearGradient(
colors: [Colors.green[400]!, Colors.green[400]!.withOpacity(0)],
begin: (isStart) ? Alignment.centerLeft : Alignment.centerRight,
end: (isStart) ? Alignment.centerRight : Alignment.centerLeft,
),
boxShadow: const [
BoxShadow(color: Color(0x22FF0000), spreadRadius: 0.0, blurRadius: 5.0),
BoxShadow(color: Color(0x66FF0000), spreadRadius: 10.0, blurRadius: 30.0),
BoxShadow(color: Color(0x22FF0000), spreadRadius: 60.0, blurRadius: 150.0),
],
);
{@end-tool}
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- Curtains
Constructors
- Curtains({Key? key, Axis scrollDirection = Axis.vertical, Decoration? startCurtain, Decoration? endCurtain, double spread = 0.0, Sensitivity sensitivity = Sensitivity.none, bool startInitVisible = false, bool endInitVisible = true, AlignmentGeometry? alignment, TextDirection? textDirection, Clip clipBehavior = Clip.hardEdge, required Widget child, Duration? duration = _350ms, Curve? curve = Curves.easeOut})
-
Wraps a scrollable child with scrim decorations while not at the start or end, alluding to unrevealed content.
const
- Curtains.drawn({Key? key, Axis? axis = Axis.vertical, Decoration? startCurtain, Decoration? endCurtain, double spread = 0.0, Sensitivity sensitivity = Sensitivity.none, bool isStartVisible = true, bool isEndVisible = true, AlignmentGeometry? alignment, TextDirection? textDirection, Clip clipBehavior = Clip.hardEdge, Widget? child, Duration? duration = _350ms, Curve? curve = Curves.easeOut})
-
These
Curtains
behave a little differently.
Instead of toggling visibility based on the scrollablechild
's extent, the startCurtain and endCurtain are static.const - Curtains.elevated({Key? key, Axis scrollDirection = Axis.vertical, double? elevation = 9.0, Color? color, Sensitivity sensitivity = Sensitivity.none, bool startInitVisible = false, bool endInitVisible = true, AlignmentGeometry? alignment, TextDirection? textDirection, Clip clipBehavior = Clip.hardEdge, required Widget child, Duration? duration = _350ms, Curve? curve = Curves.easeOut})
-
Wraps a scrollable child with scrim shadows while
not at the start or end, alluding to unrevealed content.const - Curtains.instant({Key? key, Axis scrollDirection = Axis.vertical, Decoration? startCurtain, Decoration? endCurtain, double spread = 0.0, Sensitivity sensitivity = Sensitivity.none, bool startInitVisible = false, bool endInitVisible = true, AlignmentGeometry? alignment, TextDirection? textDirection, Clip clipBehavior = Clip.hardEdge, required Widget child})
-
Wraps a scrollable child with scrim decorations while not at the start or end, alluding to unrevealed content.
const
Properties
- alignment → AlignmentGeometry?
-
Override the alignment of the child within the
Stack
that houses it and these 📜Curtains
.final - child → Widget
-
The scrollable child of this 📜
Curtains
.final - clipBehavior → Clip
-
By default this 📜
Curtains
is ClipRect-ed for easy BoxShadow support.final - color → Color?
-
When using elevation to style this 📜
Curtains
, a color may be provided to stylize the Material elevation-like shadows.final - curve → Curve?
-
When drawing 📜 Curtains, state changes are
intrinsically animated over this curve.
final
- duration → Duration?
-
When drawing 📜 Curtains, state changes are
intrinsically animated over this duration.
final
- elevation → double?
-
Recreation of
Material.elevation
utilizing Flutter's nativeMap<int, List<BoxShadow>
kElevationToShadow.final - endCurtain → Decoration?
-
The Decoration to display at the end of the scrollable child
when there is content beyond/underneath it.
(When the end of the scrollable has not been reached.)
final
- endInitVisible → bool
-
This 📜
Curtains
controls its visibility byScrollUpdateNotification
s. Override initialization visibility of this curtain with thisbool
.final - hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollDirection → Axis
-
Match scrollDirection to the scrolling direction of child.
final
- sensitivity → Sensitivity
-
With non-negative Sensitivity, the scrims of this 📜
Curtains
will change state before the scrollable reaches a min/max extent.final - spread → double
-
For scenarios where startCurtain or endCurtain necessitate
curtains with girth ― either
height
orwidth
, considering axis.final - startCurtain → Decoration?
-
The Decoration to display at the start of the scrollable child
when there is content behind/underneath it.
(When the start of the scrollable has been scrolled away from.)
final
- startInitVisible → bool
-
This 📜
Curtains
controls its visibility byScrollUpdateNotification
s. Override initialization visibility of this curtain with thisbool
.final - textDirection → TextDirection?
-
The local TextDirection. If left
null
, the ambientDirectionality.of(context)
is obtained.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _CurtainsState -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited