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
a5d0d0e5
Unverified
Commit
a5d0d0e5
authored
Mar 13, 2021
by
Darren Austin
Committed by
GitHub
Mar 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated InputDecorator to no longer reference ThemeData.accentColor. (#77999)
parent
2820d21c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
13 deletions
+92
-13
input_decorator.dart
packages/flutter/lib/src/material/input_decorator.dart
+2
-12
input_decorator_test.dart
packages/flutter/test/material/input_decorator_test.dart
+90
-1
No files found.
packages/flutter/lib/src/material/input_decorator.dart
View file @
a5d0d0e5
...
...
@@ -2019,24 +2019,14 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
Color
_getActiveColor
(
ThemeData
themeData
)
{
if
(
isFocused
)
{
switch
(
themeData
.
brightness
)
{
case
Brightness
.
dark
:
return
themeData
.
accentColor
;
case
Brightness
.
light
:
return
themeData
.
primaryColor
;
}
return
themeData
.
colorScheme
.
primary
;
}
return
themeData
.
hintColor
;
}
Color
_getDefaultBorderColor
(
ThemeData
themeData
)
{
if
(
isFocused
)
{
switch
(
themeData
.
brightness
)
{
case
Brightness
.
dark
:
return
themeData
.
accentColor
;
case
Brightness
.
light
:
return
themeData
.
primaryColor
;
}
return
themeData
.
colorScheme
.
primary
;
}
if
(
decoration
!.
filled
!)
{
return
themeData
.
hintColor
;
...
...
packages/flutter/test/material/input_decorator_test.dart
View file @
a5d0d0e5
...
...
@@ -13,6 +13,7 @@ import '../rendering/mock_canvas.dart';
Widget
buildInputDecorator
(
{
InputDecoration
decoration
=
const
InputDecoration
(),
ThemeData
?
theme
,
InputDecorationTheme
?
inputDecorationTheme
,
TextDirection
textDirection
=
TextDirection
.
ltr
,
bool
expands
=
false
,
...
...
@@ -33,7 +34,7 @@ Widget buildInputDecorator({
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
Theme
(
data:
Theme
.
of
(
context
).
copyWith
(
data:
(
theme
??
Theme
.
of
(
context
)
).
copyWith
(
inputDecorationTheme:
inputDecorationTheme
,
visualDensity:
visualDensity
,
fixTextFieldOutlineLabel:
fixTextFieldOutlineLabel
,
...
...
@@ -3595,6 +3596,94 @@ void main() {
expect
(
debugString
,
contains
(
'focusedBorder: OutlineInputBorder()'
));
});
testWidgets
(
'InputDecoration default border uses colorScheme'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
theme
=
ThemeData
.
from
(
colorScheme:
const
ColorScheme
.
light
());
final
Color
enabledColor
=
theme
.
colorScheme
.
onSurface
.
withOpacity
(
0.38
);
final
Color
hoverColor
=
Color
.
alphaBlend
(
theme
.
hoverColor
.
withOpacity
(
0.12
),
enabledColor
);
// Enabled
await
tester
.
pumpWidget
(
buildInputDecorator
(
theme:
theme
,
decoration:
const
InputDecoration
(),
),
);
await
tester
.
pumpAndSettle
();
expect
(
getBorderColor
(
tester
),
enabledColor
);
// Filled
await
tester
.
pumpWidget
(
buildInputDecorator
(
theme:
theme
,
decoration:
const
InputDecoration
(
filled:
true
,
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
getBorderColor
(
tester
),
theme
.
hintColor
);
// Hovering
await
tester
.
pumpWidget
(
buildInputDecorator
(
theme:
theme
,
isHovering:
true
,
decoration:
const
InputDecoration
(),
),
);
await
tester
.
pumpAndSettle
();
expect
(
getBorderColor
(
tester
),
hoverColor
);
// Focused
await
tester
.
pumpWidget
(
buildInputDecorator
(
theme:
theme
,
isFocused:
true
,
decoration:
const
InputDecoration
(),
),
);
await
tester
.
pumpAndSettle
();
expect
(
getBorderColor
(
tester
),
theme
.
colorScheme
.
primary
);
// Error
await
tester
.
pumpWidget
(
buildInputDecorator
(
theme:
theme
,
decoration:
const
InputDecoration
(
errorText:
'Nope'
,
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
getBorderColor
(
tester
),
theme
.
errorColor
);
// Disabled
await
tester
.
pumpWidget
(
buildInputDecorator
(
theme:
theme
,
decoration:
const
InputDecoration
(
enabled:
false
,
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
getBorderColor
(
tester
),
theme
.
disabledColor
);
// Disabled, filled
await
tester
.
pumpWidget
(
buildInputDecorator
(
theme:
theme
,
decoration:
const
InputDecoration
(
enabled:
false
,
filled:
true
,
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
getBorderColor
(
tester
),
Colors
.
transparent
);
});
testWidgets
(
'InputDecoration borders'
,
(
WidgetTester
tester
)
async
{
const
InputBorder
errorBorder
=
OutlineInputBorder
(
borderSide:
BorderSide
(
color:
Colors
.
red
,
width:
1.5
),
...
...
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