Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
c815aaed
Unverified
Commit
c815aaed
authored
Apr 14, 2022
by
Mahesh Jamdade
Committed by
GitHub
Apr 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds `isAttached` getter to DraggableScrollableController (#100269)
parent
33d14352
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
draggable_scrollable_sheet.dart
...s/flutter/lib/src/widgets/draggable_scrollable_sheet.dart
+9
-1
draggable_scrollable_sheet_test.dart
...flutter/test/widgets/draggable_scrollable_sheet_test.dart
+14
-0
No files found.
packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart
View file @
c815aaed
...
...
@@ -71,6 +71,14 @@ class DraggableScrollableController extends ChangeNotifier {
return
_attachedController
!.
extent
.
sizeToPixels
(
size
);
}
/// Returns Whether any [DraggableScrollableController] objects have attached themselves to the
/// [DraggableScrollableSheet].
///
/// If this is false, then members that interact with the [ScrollPosition],
/// such as [sizeToPixels], [size], [animateTo], and [jumpTo], must not be
/// called.
bool
get
isAttached
=>
_attachedController
!=
null
&&
_attachedController
!.
hasClients
;
/// Convert a sheet's pixel height to size (fractional value of parent container height).
double
pixelsToSize
(
double
pixels
)
{
_assertAttached
();
...
...
@@ -157,7 +165,7 @@ class DraggableScrollableController extends ChangeNotifier {
void
_assertAttached
()
{
assert
(
_attachedController
!=
null
,
isAttached
,
'DraggableScrollableController is not attached to a sheet. A DraggableScrollableController '
'must be used in a DraggableScrollableSheet before any of its methods are called.'
,
);
...
...
packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart
View file @
c815aaed
...
...
@@ -1195,4 +1195,18 @@ void main() {
// Can't use animateTo with a zero duration.
expect
(()
=>
controller
.
animateTo
(.
5
,
duration:
Duration
.
zero
,
curve:
Curves
.
linear
),
throwsAssertionError
);
});
testWidgets
(
'DraggableScrollableController must be attached before using any of its paramters'
,
(
WidgetTester
tester
)
async
{
final
DraggableScrollableController
controller
=
DraggableScrollableController
();
expect
(
controller
.
isAttached
,
false
);
expect
(()=>
controller
.
size
,
throwsAssertionError
);
final
Widget
boilerplate
=
_boilerplate
(
null
,
minChildSize:
0.4
,
controller:
controller
,
);
await
tester
.
pumpWidget
(
boilerplate
);
expect
(
controller
.
isAttached
,
true
);
expect
(
controller
.
size
,
isNotNull
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment