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
f3725d0a
Unverified
Commit
f3725d0a
authored
Mar 15, 2021
by
Hans Muller
Committed by
GitHub
Mar 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug in ButtonStyle.lerp(), in _LerpSides (#78051)
parent
4f569fb3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
button_style.dart
packages/flutter/lib/src/material/button_style.dart
+1
-1
button_style_test.dart
packages/flutter/test/material/button_style_test.dart
+34
-0
No files found.
packages/flutter/lib/src/material/button_style.dart
View file @
f3725d0a
...
...
@@ -475,7 +475,7 @@ class _LerpSides implements MaterialStateProperty<BorderSide?> {
if
(
resolvedA
==
null
)
return
BorderSide
.
lerp
(
BorderSide
(
width:
0
,
color:
resolvedB
!.
color
.
withAlpha
(
0
)),
resolvedB
,
t
);
if
(
resolvedB
==
null
)
return
BorderSide
.
lerp
(
BorderSide
(
width:
0
,
color:
resolvedA
.
color
.
withAlpha
(
0
)),
resolvedA
,
t
);
return
BorderSide
.
lerp
(
resolvedA
,
BorderSide
(
width:
0
,
color:
resolvedA
.
color
.
withAlpha
(
0
))
,
t
);
return
BorderSide
.
lerp
(
resolvedA
,
resolvedB
,
t
);
}
}
...
...
packages/flutter/test/material/button_style_test.dart
View file @
f3725d0a
...
...
@@ -151,4 +151,38 @@ void main() {
style
.
merge
(
const
ButtonStyle
())
);
});
test
(
'ButtonStyle.lerp BorderSide'
,
()
{
// This is regression test for https://github.com/flutter/flutter/pull/78051
expect
(
ButtonStyle
.
lerp
(
null
,
null
,
0
),
null
);
expect
(
ButtonStyle
.
lerp
(
null
,
null
,
0.5
),
null
);
expect
(
ButtonStyle
.
lerp
(
null
,
null
,
1
),
null
);
const
BorderSide
blackSide
=
BorderSide
(
width:
1
,
color:
Color
(
0xFF000000
));
const
BorderSide
whiteSide
=
BorderSide
(
width:
1
,
color:
Color
(
0xFFFFFFFF
));
const
BorderSide
emptyBlackSide
=
BorderSide
(
width:
0
,
color:
Color
(
0x00000000
));
final
ButtonStyle
blackStyle
=
ButtonStyle
(
side:
MaterialStateProperty
.
all
<
BorderSide
>(
blackSide
));
final
ButtonStyle
whiteStyle
=
ButtonStyle
(
side:
MaterialStateProperty
.
all
<
BorderSide
>(
whiteSide
));
// MaterialState.all<Foo>(value) properties resolve to value
// for any set of MaterialStates.
const
Set
<
MaterialState
>
states
=
<
MaterialState
>{
};
expect
(
ButtonStyle
.
lerp
(
blackStyle
,
blackStyle
,
0
)?.
side
?.
resolve
(
states
),
blackSide
);
expect
(
ButtonStyle
.
lerp
(
blackStyle
,
blackStyle
,
0.5
)?.
side
?.
resolve
(
states
),
blackSide
);
expect
(
ButtonStyle
.
lerp
(
blackStyle
,
blackStyle
,
1
)?.
side
?.
resolve
(
states
),
blackSide
);
expect
(
ButtonStyle
.
lerp
(
blackStyle
,
null
,
0
)?.
side
?.
resolve
(
states
),
blackSide
);
expect
(
ButtonStyle
.
lerp
(
blackStyle
,
null
,
0.5
)?.
side
?.
resolve
(
states
),
BorderSide
.
lerp
(
blackSide
,
emptyBlackSide
,
0.5
));
expect
(
ButtonStyle
.
lerp
(
blackStyle
,
null
,
1
)?.
side
?.
resolve
(
states
),
emptyBlackSide
);
expect
(
ButtonStyle
.
lerp
(
null
,
blackStyle
,
0
)?.
side
?.
resolve
(
states
),
emptyBlackSide
);
expect
(
ButtonStyle
.
lerp
(
null
,
blackStyle
,
0.5
)?.
side
?.
resolve
(
states
),
BorderSide
.
lerp
(
emptyBlackSide
,
blackSide
,
0.5
));
expect
(
ButtonStyle
.
lerp
(
null
,
blackStyle
,
1
)?.
side
?.
resolve
(
states
),
blackSide
);
expect
(
ButtonStyle
.
lerp
(
blackStyle
,
whiteStyle
,
0
)?.
side
?.
resolve
(
states
),
blackSide
);
expect
(
ButtonStyle
.
lerp
(
blackStyle
,
whiteStyle
,
0.5
)?.
side
?.
resolve
(
states
),
BorderSide
.
lerp
(
blackSide
,
whiteSide
,
0.5
));
expect
(
ButtonStyle
.
lerp
(
blackStyle
,
whiteStyle
,
1
)?.
side
?.
resolve
(
states
),
whiteSide
);
});
}
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