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
c6d4a6ef
Unverified
Commit
c6d4a6ef
authored
Nov 12, 2020
by
Hans Muller
Committed by
GitHub
Nov 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update OutlinedButton default outline geometry to be backwards compatible (#70393)
parent
0436886e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
37 deletions
+101
-37
outlined_button.dart
packages/flutter/lib/src/material/outlined_button.dart
+67
-1
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+28
-32
outlined_button_theme_test.dart
...ges/flutter/test/material/outlined_button_theme_test.dart
+6
-4
No files found.
packages/flutter/lib/src/material/outlined_button.dart
View file @
c6d4a6ef
...
...
@@ -242,7 +242,7 @@ class OutlinedButton extends ButtonStyleButton {
color:
Theme
.
of
(
context
).
colorScheme
.
onSurface
.
withOpacity
(
0.12
),
width:
1
,
),
shape:
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
4
))),
shape:
const
_Outline
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
4
))),
enabledMouseCursor:
SystemMouseCursors
.
click
,
disabledMouseCursor:
SystemMouseCursors
.
forbidden
,
visualDensity:
theme
.
visualDensity
,
...
...
@@ -349,3 +349,69 @@ class _OutlinedButtonWithIconChild extends StatelessWidget {
);
}
}
// This subclass only exists for the sake of backwards compatibility with the
// outline drawn by the original OutlineButton widget. The paint override
// draws a Path that's stroked with BorderSide, rather than filling a rounded
// rect whose inner path is the outer path inset by the BorderSide's width.
class
_Outline
extends
RoundedRectangleBorder
{
const
_Outline
({
BorderSide
side
=
BorderSide
.
none
,
required
BorderRadiusGeometry
borderRadius
,
})
:
super
(
side:
side
,
borderRadius:
borderRadius
);
@override
ShapeBorder
scale
(
double
t
)
{
return
_Outline
(
side:
side
.
scale
(
t
),
borderRadius:
borderRadius
*
t
,
);
}
@override
ShapeBorder
?
lerpFrom
(
ShapeBorder
?
a
,
double
t
)
{
assert
(
t
!=
null
);
if
(
a
is
_Outline
)
{
return
_Outline
(
side:
BorderSide
.
lerp
(
a
.
side
,
side
,
t
),
borderRadius:
BorderRadiusGeometry
.
lerp
(
a
.
borderRadius
,
borderRadius
,
t
)!,
);
}
return
super
.
lerpFrom
(
a
,
t
);
}
@override
ShapeBorder
?
lerpTo
(
ShapeBorder
?
b
,
double
t
)
{
assert
(
t
!=
null
);
if
(
b
is
_Outline
)
{
return
_Outline
(
side:
BorderSide
.
lerp
(
side
,
b
.
side
,
t
),
borderRadius:
BorderRadiusGeometry
.
lerp
(
borderRadius
,
b
.
borderRadius
,
t
)!,
);
}
return
super
.
lerpTo
(
b
,
t
);
}
@override
_Outline
copyWith
({
BorderSide
?
side
,
BorderRadius
?
borderRadius
})
{
return
_Outline
(
side:
side
??
this
.
side
,
borderRadius:
borderRadius
??
this
.
borderRadius
,
);
}
@override
void
paint
(
Canvas
canvas
,
Rect
rect
,
{
TextDirection
?
textDirection
})
{
switch
(
side
.
style
)
{
case
BorderStyle
.
none
:
break
;
case
BorderStyle
.
solid
:
if
(
side
.
width
==
0.0
)
{
super
.
paint
(
canvas
,
rect
,
textDirection:
textDirection
);
}
else
{
canvas
.
drawPath
(
getOuterPath
(
rect
,
textDirection:
textDirection
),
side
.
toPaint
());
}
}
}
}
packages/flutter/test/material/outlined_button_test.dart
View file @
c6d4a6ef
...
...
@@ -40,13 +40,12 @@ void main() {
expect
(
material
.
color
,
Colors
.
transparent
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
side:
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
),
),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
shape
,
isInstanceOf
<
RoundedRectangleBorder
>());
RoundedRectangleBorder
materialShape
=
material
.
shape
!
as
RoundedRectangleBorder
;
expect
(
materialShape
.
side
,
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
)));
expect
(
materialShape
.
borderRadius
,
BorderRadius
.
circular
(
4.0
));
expect
(
material
.
textStyle
!.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!.
fontSize
,
14
);
...
...
@@ -71,13 +70,12 @@ void main() {
expect
(
material
.
color
,
Colors
.
transparent
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
side:
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
),
),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
shape
,
isInstanceOf
<
RoundedRectangleBorder
>());
materialShape
=
material
.
shape
!
as
RoundedRectangleBorder
;
expect
(
materialShape
.
side
,
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
)));
expect
(
materialShape
.
borderRadius
,
BorderRadius
.
circular
(
4.0
));
expect
(
material
.
textStyle
!.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!.
fontSize
,
14
);
...
...
@@ -113,13 +111,12 @@ void main() {
expect
(
material
.
color
,
Colors
.
transparent
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
side:
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
),
),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
shape
,
isInstanceOf
<
RoundedRectangleBorder
>());
materialShape
=
material
.
shape
!
as
RoundedRectangleBorder
;
expect
(
materialShape
.
side
,
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
)));
expect
(
materialShape
.
borderRadius
,
BorderRadius
.
circular
(
4.0
));
expect
(
material
.
textStyle
!.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!.
fontSize
,
14
);
...
...
@@ -147,13 +144,12 @@ void main() {
expect
(
material
.
color
,
Colors
.
transparent
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
side:
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
),
),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
shape
,
isInstanceOf
<
RoundedRectangleBorder
>());
materialShape
=
material
.
shape
!
as
RoundedRectangleBorder
;
expect
(
materialShape
.
side
,
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
)));
expect
(
materialShape
.
borderRadius
,
BorderRadius
.
circular
(
4.0
));
expect
(
material
.
textStyle
!.
color
,
colorScheme
.
onSurface
.
withOpacity
(
0.38
));
expect
(
material
.
textStyle
!.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!.
fontSize
,
14
);
...
...
@@ -546,12 +542,12 @@ void main() {
final
Finder
outlinedButton
=
find
.
byType
(
OutlinedButton
);
// Default, not disabled.
expect
(
outlinedButton
,
paints
..
drrect
(
color:
defaultColor
));
expect
(
outlinedButton
,
paints
..
path
(
color:
defaultColor
));
// Focused.
focusNode
.
requestFocus
();
await
tester
.
pumpAndSettle
();
expect
(
outlinedButton
,
paints
..
drrect
(
color:
focusedColor
));
expect
(
outlinedButton
,
paints
..
path
(
color:
focusedColor
));
// Hovered.
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
OutlinedButton
));
...
...
@@ -562,12 +558,12 @@ void main() {
addTearDown
(
gesture
.
removePointer
);
await
gesture
.
moveTo
(
center
);
await
tester
.
pumpAndSettle
();
expect
(
outlinedButton
,
paints
..
drrect
(
color:
hoverColor
));
expect
(
outlinedButton
,
paints
..
path
(
color:
hoverColor
));
// Highlighted (pressed).
await
gesture
.
down
(
center
);
await
tester
.
pumpAndSettle
();
expect
(
outlinedButton
,
paints
..
drrect
(
color:
pressedColor
));
expect
(
outlinedButton
,
paints
..
path
(
color:
pressedColor
));
});
testWidgets
(
'OutlinedButton onPressed and onLongPress callbacks are correctly called when non-null'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/outlined_button_theme_test.dart
View file @
c6d4a6ef
...
...
@@ -34,10 +34,12 @@ void main() {
expect
(
material
.
color
,
Colors
.
transparent
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
Colors
.
black
);
expect
(
material
.
shape
,
RoundedRectangleBorder
(
side:
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
)),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
shape
,
isInstanceOf
<
RoundedRectangleBorder
>());
final
RoundedRectangleBorder
materialShape
=
material
.
shape
!
as
RoundedRectangleBorder
;
expect
(
materialShape
.
side
,
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
)));
expect
(
materialShape
.
borderRadius
,
BorderRadius
.
circular
(
4.0
));
expect
(
material
.
textStyle
!.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!.
fontSize
,
14
);
...
...
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