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
7a8c84f9
Unverified
Commit
7a8c84f9
authored
Aug 17, 2022
by
Greg Spencer
Committed by
GitHub
Aug 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some misc changes needed for MenuBar implementation. (#109555)
parent
bfdc9a6c
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
142 additions
and
31 deletions
+142
-31
chip.dart
packages/flutter/lib/src/material/chip.dart
+1
-1
material_state.dart
packages/flutter/lib/src/material/material_state.dart
+7
-1
snack_bar.dart
packages/flutter/lib/src/material/snack_bar.dart
+6
-5
edge_insets.dart
packages/flutter/lib/src/painting/edge_insets.dart
+21
-0
flex.dart
packages/flutter/lib/src/rendering/flex.dart
+5
-6
focus_traversal.dart
packages/flutter/lib/src/widgets/focus_traversal.dart
+34
-16
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+1
-1
material_state_property_test.dart
...s/flutter/test/material/material_state_property_test.dart
+8
-0
edge_insets_test.dart
packages/flutter/test/painting/edge_insets_test.dart
+58
-0
shortcuts_test.dart
packages/flutter/test/widgets/shortcuts_test.dart
+1
-1
No files found.
packages/flutter/lib/src/material/chip.dart
View file @
7a8c84f9
...
...
@@ -1320,7 +1320,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
}
}
/// Redirects the [
position
.dy] passed to [RenderBox.hitTest] to the vertical
/// Redirects the [
buttonRect
.dy] passed to [RenderBox.hitTest] to the vertical
/// center of the widget.
///
/// The primary purpose of this widget is to allow padding around the [RawChip]
...
...
packages/flutter/lib/src/material/material_state.dart
View file @
7a8c84f9
...
...
@@ -722,7 +722,13 @@ class MaterialStatePropertyAll<T> implements MaterialStateProperty<T> {
T
resolve
(
Set
<
MaterialState
>
states
)
=>
value
;
@override
String
toString
()
=>
'MaterialStatePropertyAll(
$value
)'
;
String
toString
()
{
if
(
value
is
double
)
{
return
'MaterialStatePropertyAll(
${debugFormatDouble(value as double)}
)'
;
}
else
{
return
'MaterialStatePropertyAll(
$value
)'
;
}
}
}
/// Manages a set of [MaterialState]s and notifies listeners of changes.
...
...
packages/flutter/lib/src/material/snack_bar.dart
View file @
7a8c84f9
...
...
@@ -232,11 +232,12 @@ class SnackBar extends StatefulWidget {
/// Typically a [Text] widget.
final
Widget
content
;
/// The snack bar's background color. If not specified it will use
/// [SnackBarThemeData.backgroundColor] of [ThemeData.snackBarTheme]. If that
/// is not specified it will default to a dark variation of
/// [ColorScheme.surface] for light themes, or [ColorScheme.onSurface] for
/// dark themes.
/// The snack bar's background color.
///
/// If not specified, it will use [SnackBarThemeData.backgroundColor] of
/// [ThemeData.snackBarTheme]. If that is not specified it will default to a
/// dark variation of [ColorScheme.surface] for light themes, or
/// [ColorScheme.onSurface] for dark themes.
final
Color
?
backgroundColor
;
/// The z-coordinate at which to place the snack bar. This controls the size
...
...
packages/flutter/lib/src/painting/edge_insets.dart
View file @
7a8c84f9
...
...
@@ -674,6 +674,27 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry {
this
.
bottom
=
0.0
,
});
/// Creates insets with symmetric vertical and horizontal offsets.
///
/// This is equivalent to [EdgeInsets.symmetric], since the inset is the same
/// with either [TextDirection]. This constructor is just a convenience for
/// type compatibilty.
///
/// {@tool snippet}
/// Eight pixel margin above and below, no horizontal margins:
///
/// ```dart
/// const EdgeInsetsDirectional.symmetric(vertical: 8.0)
/// ```
/// {@end-tool}
const
EdgeInsetsDirectional
.
symmetric
({
double
horizontal
=
0.0
,
double
vertical
=
0.0
,
})
:
start
=
horizontal
,
end
=
horizontal
,
top
=
vertical
,
bottom
=
vertical
;
/// Creates insets where all the offsets are `value`.
///
/// {@tool snippet}
...
...
packages/flutter/lib/src/rendering/flex.dart
View file @
7a8c84f9
...
...
@@ -991,10 +991,11 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
final
double
remainingSpace
=
math
.
max
(
0.0
,
actualSizeDelta
);
late
final
double
leadingSpace
;
late
final
double
betweenSpace
;
// flipMainAxis is used to decide whether to lay out left-to-right/top-to-bottom (false), or
// right-to-left/bottom-to-top (true). The _startIsTopLeft will return null if there's only
// one child and the relevant direction is null, in which case we arbitrarily decide not to
// flip, but that doesn't have any detectable effect.
// flipMainAxis is used to decide whether to lay out
// left-to-right/top-to-bottom (false), or right-to-left/bottom-to-top
// (true). The _startIsTopLeft will return null if there's only one child
// and the relevant direction is null, in which case we arbitrarily decide
// to flip, but that doesn't have any detectable effect.
final
bool
flipMainAxis
=
!(
_startIsTopLeft
(
direction
,
textDirection
,
verticalDirection
)
??
true
);
switch
(
_mainAxisAlignment
)
{
case
MainAxisAlignment
.
start
:
...
...
@@ -1104,8 +1105,6 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
);
assert
(()
{
// Only set this if it's null to save work. It gets reset to null if the
// _direction changes.
final
List
<
DiagnosticsNode
>
debugOverflowHints
=
<
DiagnosticsNode
>[
ErrorDescription
(
'The overflowing
$runtimeType
has an orientation of
$_direction
.'
,
...
...
packages/flutter/lib/src/widgets/focus_traversal.dart
View file @
7a8c84f9
...
...
@@ -129,17 +129,24 @@ abstract class FocusTraversalPolicy with Diagnosticable {
///
/// The `currentNode` argument must not be null.
///
/// The default implementation returns the [FocusScopeNode.focusedChild], if
/// set, on the nearest scope of the `currentNode`, otherwise, returns the
/// first node from [sortDescendants], or the given `currentNode` if there are
/// no descendants.
/// If `ignoreCurrentFocus` is false or not given, this function returns the
/// [FocusScopeNode.focusedChild], if set, on the nearest scope of the
/// `currentNode`, otherwise, returns the first node from [sortDescendants],
/// or the given `currentNode` if there are no descendants.
///
/// If `ignoreCurrentFocus` is true, then the algorithm returns the first node
/// from [sortDescendants], or the given `currentNode` if there are no
/// descendants.
///
/// See also:
///
/// * [next], the function that is called to move the focus to the next node.
/// * [DirectionalFocusTraversalPolicyMixin.findFirstFocusInDirection], a
/// function that finds the first focusable widget in a particular direction.
FocusNode
?
findFirstFocus
(
FocusNode
currentNode
)
=>
_findInitialFocus
(
currentNode
);
/// function that finds the first focusable widget in a particular
/// direction.
FocusNode
?
findFirstFocus
(
FocusNode
currentNode
,
{
bool
ignoreCurrentFocus
=
false
})
{
return
_findInitialFocus
(
currentNode
,
ignoreCurrentFocus:
ignoreCurrentFocus
);
}
/// Returns the node that should receive focus if focus is traversing
/// backwards, and there is no current focus.
...
...
@@ -150,23 +157,29 @@ abstract class FocusTraversalPolicy with Diagnosticable {
///
/// The `currentNode` argument must not be null.
///
/// The default implementation returns the [FocusScopeNode.focusedChild], if
/// set, on the nearest scope of the `currentNode`, otherwise, returns the
/// last node from [sortDescendants], or the given `currentNode` if there are
/// no descendants.
/// If `ignoreCurrentFocus` is false or not given, this function returns the
/// [FocusScopeNode.focusedChild], if set, on the nearest scope of the
/// `currentNode`, otherwise, returns the last node from [sortDescendants],
/// or the given `currentNode` if there are no descendants.
///
/// If `ignoreCurrentFocus` is true, then the algorithm returns the last node
/// from [sortDescendants], or the given `currentNode` if there are no
/// descendants.
///
/// See also:
///
/// * [previous], the function that is called to move the focus to the next node.
/// * [DirectionalFocusTraversalPolicyMixin.findFirstFocusInDirection], a
/// function that finds the first focusable widget in a particular direction.
FocusNode
findLastFocus
(
FocusNode
currentNode
)
=>
_findInitialFocus
(
currentNode
,
fromEnd:
true
);
FocusNode
findLastFocus
(
FocusNode
currentNode
,
{
bool
ignoreCurrentFocus
=
false
})
{
return
_findInitialFocus
(
currentNode
,
fromEnd:
true
,
ignoreCurrentFocus:
ignoreCurrentFocus
);
}
FocusNode
_findInitialFocus
(
FocusNode
currentNode
,
{
bool
fromEnd
=
false
})
{
FocusNode
_findInitialFocus
(
FocusNode
currentNode
,
{
bool
fromEnd
=
false
,
bool
ignoreCurrentFocus
=
false
})
{
assert
(
currentNode
!=
null
);
final
FocusScopeNode
scope
=
currentNode
.
nearestScope
!;
FocusNode
?
candidate
=
scope
.
focusedChild
;
if
(
candidate
==
null
&&
scope
.
descendants
.
isNotEmpty
)
{
if
(
ignoreCurrentFocus
||
candidate
==
null
&&
scope
.
descendants
.
isNotEmpty
)
{
final
Iterable
<
FocusNode
>
sorted
=
_sortAllDescendants
(
scope
,
currentNode
);
if
(
sorted
.
isEmpty
)
{
candidate
=
null
;
...
...
@@ -200,7 +213,6 @@ abstract class FocusTraversalPolicy with Diagnosticable {
///
/// The default implementation does nothing.
@mustCallSuper
@protected
void
invalidateScopeData
(
FocusScopeNode
node
)
{}
/// This is called whenever the given [node] is re-parented into a new scope,
...
...
@@ -1724,6 +1736,12 @@ class DirectionalFocusIntent extends Intent {
///
/// Defaults to true.
final
bool
ignoreTextFields
;
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
properties
.
add
(
EnumProperty
<
TraversalDirection
>(
'direction'
,
direction
));
}
}
/// An [Action] that moves the focus to the focusable node in the direction
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
7a8c84f9
...
...
@@ -1003,7 +1003,7 @@ abstract class State<T extends StatefulWidget> with Diagnosticable {
/// Called whenever the widget configuration changes.
///
/// If the parent widget rebuilds and request that this location in the tree
/// If the parent widget rebuilds and request
s
that this location in the tree
/// update to display a new widget with the same [runtimeType] and
/// [Widget.key], the framework will update the [widget] property of this
/// [State] object to refer to the new widget and then call this method
...
...
packages/flutter/test/material/material_state_property_test.dart
View file @
7a8c84f9
...
...
@@ -43,6 +43,14 @@ void main() {
expect
(
value
.
resolve
(<
MaterialState
>{
MaterialState
.
error
}),
123
);
});
test
(
'toString formats correctly'
,
()
{
const
MaterialStateProperty
<
Color
?>
colorProperty
=
MaterialStatePropertyAll
<
Color
?>(
Color
(
0xFFFFFFFF
));
expect
(
colorProperty
.
toString
(),
equals
(
'MaterialStatePropertyAll(Color(0xffffffff))'
));
const
MaterialStateProperty
<
double
?>
doubleProperty
=
MaterialStatePropertyAll
<
double
?>(
33
+
1
/
3
);
expect
(
doubleProperty
.
toString
(),
equals
(
'MaterialStatePropertyAll(33.3)'
));
});
test
(
"Can interpolate between two MaterialStateProperty's"
,
()
{
const
MaterialStateProperty
<
TextStyle
?>
textStyle1
=
MaterialStatePropertyAll
<
TextStyle
?>(
TextStyle
(
fontSize:
14.0
),
...
...
packages/flutter/test/painting/edge_insets_test.dart
View file @
7a8c84f9
...
...
@@ -6,6 +6,64 @@ import 'package:flutter/painting.dart';
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'EdgeInsets constructors'
,
()
{
// fromLTRB
final
EdgeInsets
ltrbLtr
=
const
EdgeInsets
.
fromLTRB
(
10
,
20
,
30
,
40
).
resolve
(
TextDirection
.
ltr
);
expect
(
ltrbLtr
.
left
,
10
);
expect
(
ltrbLtr
.
top
,
20
);
expect
(
ltrbLtr
.
right
,
30
);
expect
(
ltrbLtr
.
bottom
,
40
);
final
EdgeInsets
ltrbRtl
=
const
EdgeInsets
.
fromLTRB
(
10
,
20
,
30
,
40
).
resolve
(
TextDirection
.
rtl
);
expect
(
ltrbRtl
.
left
,
10
);
expect
(
ltrbRtl
.
top
,
20
);
expect
(
ltrbRtl
.
right
,
30
);
expect
(
ltrbRtl
.
bottom
,
40
);
// all
const
EdgeInsets
all
=
EdgeInsets
.
all
(
10
);
expect
(
all
.
resolve
(
TextDirection
.
ltr
),
equals
(
const
EdgeInsets
.
fromLTRB
(
10
,
10
,
10
,
10
)));
expect
(
all
.
resolve
(
TextDirection
.
rtl
),
equals
(
const
EdgeInsets
.
fromLTRB
(
10
,
10
,
10
,
10
)));
// only
const
EdgeInsets
only
=
EdgeInsets
.
only
(
left:
10
,
top:
20
,
right:
30
,
bottom:
40
);
expect
(
only
.
resolve
(
TextDirection
.
ltr
),
equals
(
const
EdgeInsets
.
fromLTRB
(
10
,
20
,
30
,
40
)));
expect
(
only
.
resolve
(
TextDirection
.
rtl
),
equals
(
const
EdgeInsets
.
fromLTRB
(
10
,
20
,
30
,
40
)));
// symmetric
const
EdgeInsets
symmetric
=
EdgeInsets
.
symmetric
(
horizontal:
10
,
vertical:
20
);
expect
(
symmetric
.
resolve
(
TextDirection
.
ltr
),
equals
(
const
EdgeInsets
.
fromLTRB
(
10
,
20
,
10
,
20
)));
expect
(
symmetric
.
resolve
(
TextDirection
.
rtl
),
equals
(
const
EdgeInsets
.
fromLTRB
(
10
,
20
,
10
,
20
)));
});
test
(
'EdgeInsetsDirectional constructors'
,
()
{
// fromSTEB
final
EdgeInsets
stebLtr
=
const
EdgeInsetsDirectional
.
fromSTEB
(
10
,
20
,
30
,
40
).
resolve
(
TextDirection
.
ltr
);
expect
(
stebLtr
.
left
,
10
);
expect
(
stebLtr
.
top
,
20
);
expect
(
stebLtr
.
right
,
30
);
expect
(
stebLtr
.
bottom
,
40
);
final
EdgeInsets
stebRtl
=
const
EdgeInsetsDirectional
.
fromSTEB
(
10
,
20
,
30
,
40
).
resolve
(
TextDirection
.
rtl
);
expect
(
stebRtl
.
left
,
30
);
expect
(
stebRtl
.
top
,
20
);
expect
(
stebRtl
.
right
,
10
);
expect
(
stebRtl
.
bottom
,
40
);
// all
const
EdgeInsetsDirectional
all
=
EdgeInsetsDirectional
.
all
(
10
);
expect
(
all
.
resolve
(
TextDirection
.
ltr
),
equals
(
const
EdgeInsets
.
fromLTRB
(
10
,
10
,
10
,
10
)));
expect
(
all
.
resolve
(
TextDirection
.
rtl
),
equals
(
const
EdgeInsets
.
fromLTRB
(
10
,
10
,
10
,
10
)));
// only
const
EdgeInsetsDirectional
directional
=
EdgeInsetsDirectional
.
only
(
start:
10
,
top:
20
,
end:
30
,
bottom:
40
);
expect
(
directional
.
resolve
(
TextDirection
.
ltr
),
const
EdgeInsets
.
fromLTRB
(
10
,
20
,
30
,
40
));
expect
(
directional
.
resolve
(
TextDirection
.
rtl
),
const
EdgeInsets
.
fromLTRB
(
30
,
20
,
10
,
40
));
// symmetric
const
EdgeInsetsDirectional
symmetric
=
EdgeInsetsDirectional
.
symmetric
(
horizontal:
10
,
vertical:
20
);
expect
(
symmetric
.
resolve
(
TextDirection
.
ltr
),
equals
(
const
EdgeInsets
.
fromLTRB
(
10
,
20
,
10
,
20
)));
expect
(
symmetric
.
resolve
(
TextDirection
.
rtl
),
equals
(
const
EdgeInsets
.
fromLTRB
(
10
,
20
,
10
,
20
)));
});
test
(
'EdgeInsets control test'
,
()
{
const
EdgeInsets
insets
=
EdgeInsets
.
fromLTRB
(
5.0
,
7.0
,
11.0
,
13.0
);
...
...
packages/flutter/test/widgets/shortcuts_test.dart
View file @
7a8c84f9
...
...
@@ -910,7 +910,7 @@ void main() {
expect
(
description
[
0
],
equalsIgnoringHashCodes
(
'shortcuts: {{Shift + Key A}: ActivateIntent#00000, {Shift + Arrow Right}: DirectionalFocusIntent#00000}'
,
'shortcuts: {{Shift + Key A}: ActivateIntent#00000, {Shift + Arrow Right}: DirectionalFocusIntent#00000
(direction: right)
}'
,
),
);
});
...
...
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