Skip to content

Commit e8cdf85

Browse files
committed
Use names for better readability
1 parent 9e71d89 commit e8cdf85

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

lib/draggable_home.dart

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,19 @@ class _DraggableHomeState extends State<DraggableHome> {
185185
stream: CombineLatestStream.list<bool>(
186186
[isFullyCollapsed.stream, isFullyExpanded.stream]),
187187
builder: (BuildContext context, AsyncSnapshot<List<bool>> snapshot) {
188-
List<bool> streams = (snapshot.data ?? [false, false]);
188+
final List<bool> streams = (snapshot.data ?? [false, false]);
189+
final bool fullyCollapsed = streams[0];
190+
final bool fullyExpanded = streams[1];
189191

190192
return SliverAppBar(
191193
leading: widget.alwaysShowLeadingAndAction
192194
? widget.leading
193-
: !streams[0]
195+
: !fullyCollapsed
194196
? SizedBox()
195197
: widget.leading,
196198
actions: widget.alwaysShowLeadingAndAction
197199
? widget.actions
198-
: !streams[0]
200+
: !fullyCollapsed
199201
? []
200202
: widget.actions,
201203
elevation: 0,
@@ -205,21 +207,23 @@ class _DraggableHomeState extends State<DraggableHome> {
205207
title: widget.alwaysShowTitle
206208
? widget.title
207209
: AnimatedOpacity(
208-
opacity: streams[0] ? 1 : 0,
210+
opacity: fullyCollapsed ? 1 : 0,
209211
duration: Duration(milliseconds: 100),
210212
child: widget.title,
211213
),
212214
collapsedHeight: appBarHeight,
213-
expandedHeight: streams[1] ? fullyExpandedHeight : expandedHeight,
215+
expandedHeight:
216+
fullyExpanded ? fullyExpandedHeight : expandedHeight,
214217
flexibleSpace: Stack(
215218
children: [
216219
FlexibleSpaceBar(
217220
background: Container(
218-
child: streams[1]
219-
? (widget.expandedBody == null
220-
? Container()
221-
: widget.expandedBody)
222-
: widget.headerWidget),
221+
child: fullyExpanded
222+
? (widget.expandedBody == null
223+
? Container()
224+
: widget.expandedBody)
225+
: widget.headerWidget,
226+
),
223227
),
224228
Positioned(
225229
bottom: -1,
@@ -233,15 +237,15 @@ class _DraggableHomeState extends State<DraggableHome> {
233237
padding: EdgeInsets.only(left: 10, right: 10),
234238
curve: Curves.easeInOutCirc,
235239
duration: Duration(milliseconds: 100),
236-
height: streams[0]
240+
height: fullyCollapsed
237241
? 0
238-
: streams[1]
242+
: fullyExpanded
239243
? 0
240244
: kToolbarHeight,
241245
width: MediaQuery.of(context).size.width,
242-
child: streams[0]
246+
child: fullyCollapsed
243247
? SizedBox()
244-
: streams[1]
248+
: fullyExpanded
245249
? SizedBox()
246250
: widget.headerBottomBar ?? Container(),
247251
),
@@ -251,7 +255,7 @@ class _DraggableHomeState extends State<DraggableHome> {
251255
stretchTriggerOffset: widget.stretchTriggerOffset,
252256
onStretchTrigger: widget.fullyStretchable
253257
? () async {
254-
if (streams[1] == false) isFullyExpanded.add(true);
258+
if (!fullyExpanded) isFullyExpanded.add(true);
255259
}
256260
: null,
257261
);

0 commit comments

Comments
 (0)