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
e1adc96d
Unverified
Commit
e1adc96d
authored
Nov 07, 2022
by
Pedro Massango
Committed by
GitHub
Nov 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: provide a way to set the initial child's alignment (#114745)
InteractiveViewer.alignment parameter
parent
3cde69e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
interactive_viewer.dart
packages/flutter/lib/src/widgets/interactive_viewer.dart
+10
-0
interactive_viewer_test.dart
packages/flutter/test/widgets/interactive_viewer_test.dart
+16
-0
No files found.
packages/flutter/lib/src/widgets/interactive_viewer.dart
View file @
e1adc96d
...
@@ -87,6 +87,7 @@ class InteractiveViewer extends StatefulWidget {
...
@@ -87,6 +87,7 @@ class InteractiveViewer extends StatefulWidget {
this
.
scaleEnabled
=
true
,
this
.
scaleEnabled
=
true
,
this
.
scaleFactor
=
200.0
,
this
.
scaleFactor
=
200.0
,
this
.
transformationController
,
this
.
transformationController
,
this
.
alignment
,
required
Widget
this
.
child
,
required
Widget
this
.
child
,
})
:
assert
(
alignPanAxis
!=
null
),
})
:
assert
(
alignPanAxis
!=
null
),
assert
(
panAxis
!=
null
),
assert
(
panAxis
!=
null
),
...
@@ -141,6 +142,7 @@ class InteractiveViewer extends StatefulWidget {
...
@@ -141,6 +142,7 @@ class InteractiveViewer extends StatefulWidget {
this
.
scaleEnabled
=
true
,
this
.
scaleEnabled
=
true
,
this
.
scaleFactor
=
200.0
,
this
.
scaleFactor
=
200.0
,
this
.
transformationController
,
this
.
transformationController
,
this
.
alignment
,
required
InteractiveViewerWidgetBuilder
this
.
builder
,
required
InteractiveViewerWidgetBuilder
this
.
builder
,
})
:
assert
(
panAxis
!=
null
),
})
:
assert
(
panAxis
!=
null
),
assert
(
builder
!=
null
),
assert
(
builder
!=
null
),
...
@@ -166,6 +168,9 @@ class InteractiveViewer extends StatefulWidget {
...
@@ -166,6 +168,9 @@ class InteractiveViewer extends StatefulWidget {
constrained
=
false
,
constrained
=
false
,
child
=
null
;
child
=
null
;
/// The alignment of the child's origin, relative to the size of the box.
final
Alignment
?
alignment
;
/// If set to [Clip.none], the child may extend beyond the size of the InteractiveViewer,
/// If set to [Clip.none], the child may extend beyond the size of the InteractiveViewer,
/// but it will not receive gestures in these areas.
/// but it will not receive gestures in these areas.
/// Be sure that the InteractiveViewer is the desired size when using [Clip.none].
/// Be sure that the InteractiveViewer is the desired size when using [Clip.none].
...
@@ -1096,6 +1101,7 @@ class _InteractiveViewerState extends State<InteractiveViewer> with TickerProvid
...
@@ -1096,6 +1101,7 @@ class _InteractiveViewerState extends State<InteractiveViewer> with TickerProvid
clipBehavior:
widget
.
clipBehavior
,
clipBehavior:
widget
.
clipBehavior
,
constrained:
widget
.
constrained
,
constrained:
widget
.
constrained
,
matrix:
_transformationController
!.
value
,
matrix:
_transformationController
!.
value
,
alignment:
widget
.
alignment
,
child:
widget
.
child
!,
child:
widget
.
child
!,
);
);
}
else
{
}
else
{
...
@@ -1110,6 +1116,7 @@ class _InteractiveViewerState extends State<InteractiveViewer> with TickerProvid
...
@@ -1110,6 +1116,7 @@ class _InteractiveViewerState extends State<InteractiveViewer> with TickerProvid
childKey:
_childKey
,
childKey:
_childKey
,
clipBehavior:
widget
.
clipBehavior
,
clipBehavior:
widget
.
clipBehavior
,
constrained:
widget
.
constrained
,
constrained:
widget
.
constrained
,
alignment:
widget
.
alignment
,
matrix:
matrix
,
matrix:
matrix
,
child:
widget
.
builder
!(
child:
widget
.
builder
!(
context
,
context
,
...
@@ -1143,6 +1150,7 @@ class _InteractiveViewerBuilt extends StatelessWidget {
...
@@ -1143,6 +1150,7 @@ class _InteractiveViewerBuilt extends StatelessWidget {
required
this
.
clipBehavior
,
required
this
.
clipBehavior
,
required
this
.
constrained
,
required
this
.
constrained
,
required
this
.
matrix
,
required
this
.
matrix
,
required
this
.
alignment
,
});
});
final
Widget
child
;
final
Widget
child
;
...
@@ -1150,11 +1158,13 @@ class _InteractiveViewerBuilt extends StatelessWidget {
...
@@ -1150,11 +1158,13 @@ class _InteractiveViewerBuilt extends StatelessWidget {
final
Clip
clipBehavior
;
final
Clip
clipBehavior
;
final
bool
constrained
;
final
bool
constrained
;
final
Matrix4
matrix
;
final
Matrix4
matrix
;
final
Alignment
?
alignment
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
Widget
child
=
Transform
(
Widget
child
=
Transform
(
transform:
matrix
,
transform:
matrix
,
alignment:
alignment
,
child:
KeyedSubtree
(
child:
KeyedSubtree
(
key:
childKey
,
key:
childKey
,
child:
this
.
child
,
child:
this
.
child
,
...
...
packages/flutter/test/widgets/interactive_viewer_test.dart
View file @
e1adc96d
...
@@ -1650,6 +1650,22 @@ void main() {
...
@@ -1650,6 +1650,22 @@ void main() {
expect
(
scaleHighZoomedIn
-
scaleHighZoomedOut
,
lessThan
(
scaleZoomedIn
-
scaleZoomedOut
));
expect
(
scaleHighZoomedIn
-
scaleHighZoomedOut
,
lessThan
(
scaleZoomedIn
-
scaleZoomedOut
));
});
});
testWidgets
(
'alignment argument is used properly'
,
(
WidgetTester
tester
)
async
{
const
Alignment
alignment
=
Alignment
.
center
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
InteractiveViewer
(
alignment:
alignment
,
child:
Container
(),
),
),
));
final
Transform
transform
=
tester
.
firstWidget
(
find
.
byType
(
Transform
));
expect
(
transform
.
alignment
,
alignment
);
});
testWidgets
(
'interactionEndFrictionCoefficient'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'interactionEndFrictionCoefficient'
,
(
WidgetTester
tester
)
async
{
// Use the default interactionEndFrictionCoefficient.
// Use the default interactionEndFrictionCoefficient.
final
TransformationController
transformationController1
=
TransformationController
();
final
TransformationController
transformationController1
=
TransformationController
();
...
...
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