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
5054b6e5
Unverified
Commit
5054b6e5
authored
2 years ago
by
Bernardo Ferrari
Committed by
GitHub
2 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Non-Uniform Border to Border. (#121921)
Add Non-Uniform Border to Border.
parent
59c9d4e8
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
245 additions
and
56 deletions
+245
-56
box_border.dart
packages/flutter/lib/src/painting/box_border.dart
+137
-46
data_table_test.dart
packages/flutter/test/material/data_table_test.dart
+1
-5
border_test.dart
packages/flutter/test/painting/border_test.dart
+107
-5
No files found.
packages/flutter/lib/src/painting/box_border.dart
View file @
5054b6e5
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/data_table_test.dart
View file @
5054b6e5
...
@@ -1749,11 +1749,7 @@ void main() {
...
@@ -1749,11 +1749,7 @@ void main() {
);
);
expect
(
expect
(
find
.
ancestor
(
of:
find
.
byType
(
Table
),
matching:
find
.
byType
(
Container
)),
find
.
ancestor
(
of:
find
.
byType
(
Table
),
matching:
find
.
byType
(
Container
)),
paints
paints
..
drrect
(
color:
borderColor
),
..
path
(
color:
borderColor
)
..
path
(
color:
borderColor
)
..
path
(
color:
borderColor
)
..
path
(
color:
borderColor
),
);
);
expect
(
expect
(
tester
.
getTopLeft
(
find
.
byType
(
Table
)),
tester
.
getTopLeft
(
find
.
byType
(
Table
)),
...
...
This diff is collapsed.
Click to expand it.
packages/flutter/test/painting/border_test.dart
View file @
5054b6e5
...
@@ -2,8 +2,7 @@
...
@@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
show
FlutterError
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
class
TestCanvas
implements
Canvas
{
class
TestCanvas
implements
Canvas
{
...
@@ -264,8 +263,8 @@ void main() {
...
@@ -264,8 +263,8 @@ void main() {
// Border.all supports all StrokeAlign values.
// Border.all supports all StrokeAlign values.
// Border() supports [BorderSide.strokeAlignInside] only.
// Border() supports [BorderSide.strokeAlignInside] only.
const
Border
(
const
Border
(
left:
BorderSide
(
strokeAlign:
BorderSide
.
strokeAlignCenter
),
left:
BorderSide
(
strokeAlign:
BorderSide
.
strokeAlignCenter
,
color:
Color
(
0xff000001
)
),
right:
BorderSide
(
strokeAlign:
BorderSide
.
strokeAlignOutside
),
right:
BorderSide
(
strokeAlign:
BorderSide
.
strokeAlignOutside
,
color:
Color
(
0xff000002
)
),
).
paint
(
canvas
,
const
Rect
.
fromLTWH
(
10.0
,
20.0
,
30.0
,
40.0
));
).
paint
(
canvas
,
const
Rect
.
fromLTWH
(
10.0
,
20.0
,
30.0
,
40.0
));
}
on
FlutterError
catch
(
e
)
{
}
on
FlutterError
catch
(
e
)
{
error
=
e
;
error
=
e
;
...
@@ -274,7 +273,7 @@ void main() {
...
@@ -274,7 +273,7 @@ void main() {
expect
(
error
.
diagnostics
.
length
,
1
);
expect
(
error
.
diagnostics
.
length
,
1
);
expect
(
expect
(
error
.
diagnostics
[
0
].
toStringDeep
(),
error
.
diagnostics
[
0
].
toStringDeep
(),
'A Border can only draw strokeAlign different than
\n
BorderSide.strokeAlignInside on
uniform border
s.
\n
'
,
'A Border can only draw strokeAlign different than
\n
BorderSide.strokeAlignInside on
borders with uniform colors and
\n
style
s.
\n
'
,
);
);
});
});
...
@@ -299,5 +298,108 @@ void main() {
...
@@ -299,5 +298,108 @@ void main() {
const
BorderSide
outsideSide
=
BorderSide
(
width:
10
,
strokeAlign:
BorderSide
.
strokeAlignOutside
);
const
BorderSide
outsideSide
=
BorderSide
(
width:
10
,
strokeAlign:
BorderSide
.
strokeAlignOutside
);
const
BorderDirectional
outsideBorderDirectional
=
BorderDirectional
(
top:
outsideSide
,
bottom:
outsideSide
,
start:
outsideSide
,
end:
outsideSide
);
const
BorderDirectional
outsideBorderDirectional
=
BorderDirectional
(
top:
outsideSide
,
bottom:
outsideSide
,
start:
outsideSide
,
end:
outsideSide
);
expect
(
outsideBorderDirectional
.
dimensions
,
EdgeInsetsDirectional
.
zero
);
expect
(
outsideBorderDirectional
.
dimensions
,
EdgeInsetsDirectional
.
zero
);
const
Border
nonUniformBorder
=
Border
(
left:
BorderSide
(
width:
5
),
top:
BorderSide
(
width:
10
,
strokeAlign:
BorderSide
.
strokeAlignCenter
),
right:
BorderSide
(
width:
15
,
strokeAlign:
BorderSide
.
strokeAlignOutside
),
bottom:
BorderSide
(
width:
20
),
);
expect
(
nonUniformBorder
.
dimensions
,
const
EdgeInsets
.
fromLTRB
(
5
,
5
,
0
,
20
));
const
BorderDirectional
nonUniformBorderDirectional
=
BorderDirectional
(
start:
BorderSide
(
width:
5
),
top:
BorderSide
(
width:
10
,
strokeAlign:
BorderSide
.
strokeAlignCenter
),
end:
BorderSide
(
width:
15
,
strokeAlign:
BorderSide
.
strokeAlignOutside
),
bottom:
BorderSide
(
width:
20
),
);
expect
(
nonUniformBorderDirectional
.
dimensions
,
const
EdgeInsetsDirectional
.
fromSTEB
(
5
,
5
,
0
,
20
));
});
testWidgets
(
'Non-Uniform Border variations'
,
(
WidgetTester
tester
)
async
{
Widget
buildWidget
({
required
BoxBorder
border
,
BorderRadius
?
borderRadius
,
BoxShape
boxShape
=
BoxShape
.
rectangle
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
DecoratedBox
(
decoration:
BoxDecoration
(
shape:
boxShape
,
border:
border
,
borderRadius:
borderRadius
,
),
),
);
}
// This is used to test every allowed non-uniform border combination.
const
Border
allowedBorderVariations
=
Border
(
left:
BorderSide
(
width:
5
),
top:
BorderSide
(
width:
10
,
strokeAlign:
BorderSide
.
strokeAlignCenter
),
right:
BorderSide
(
width:
15
,
strokeAlign:
BorderSide
.
strokeAlignOutside
),
bottom:
BorderSide
(
width:
20
),
);
// This falls into non-uniform border because of strokeAlign.
await
tester
.
pumpWidget
(
buildWidget
(
border:
allowedBorderVariations
));
expect
(
tester
.
takeException
(),
isNull
,
reason:
'Border with non-uniform strokeAlign should not fail.'
);
await
tester
.
pumpWidget
(
buildWidget
(
border:
allowedBorderVariations
,
borderRadius:
BorderRadius
.
circular
(
25
),
));
expect
(
tester
.
takeException
(),
isNull
);
await
tester
.
pumpWidget
(
buildWidget
(
border:
allowedBorderVariations
,
boxShape:
BoxShape
.
circle
));
expect
(
tester
.
takeException
(),
isNull
);
await
tester
.
pumpWidget
(
buildWidget
(
border:
const
Border
(
left:
BorderSide
(
width:
5
,
style:
BorderStyle
.
none
),
top:
BorderSide
(
width:
10
),
right:
BorderSide
(
width:
15
),
bottom:
BorderSide
(
width:
20
),
),
borderRadius:
BorderRadius
.
circular
(
25
),
),
);
expect
(
tester
.
takeException
(),
isAssertionError
,
reason:
'Border with non-uniform styles should fail with borderRadius.'
);
await
tester
.
pumpWidget
(
buildWidget
(
border:
const
Border
(
left:
BorderSide
(
width:
5
,
color:
Color
(
0xff123456
)),
top:
BorderSide
(
width:
10
),
right:
BorderSide
(
width:
15
),
bottom:
BorderSide
(
width:
20
),
),
borderRadius:
BorderRadius
.
circular
(
20
),
),
);
expect
(
tester
.
takeException
(),
isAssertionError
,
reason:
'Border with non-uniform colors should fail with borderRadius.'
);
// Tests for BorderDirectional.
const
BorderDirectional
allowedBorderDirectionalVariations
=
BorderDirectional
(
start:
BorderSide
(
width:
5
),
top:
BorderSide
(
width:
10
,
strokeAlign:
BorderSide
.
strokeAlignCenter
),
end:
BorderSide
(
width:
15
,
strokeAlign:
BorderSide
.
strokeAlignOutside
),
bottom:
BorderSide
(
width:
20
),
);
await
tester
.
pumpWidget
(
buildWidget
(
border:
allowedBorderDirectionalVariations
));
expect
(
tester
.
takeException
(),
isNull
);
await
tester
.
pumpWidget
(
buildWidget
(
border:
allowedBorderDirectionalVariations
,
borderRadius:
BorderRadius
.
circular
(
25
),
));
expect
(
tester
.
takeException
(),
isNull
,
reason:
'BorderDirectional should not fail with uniform styles and colors.'
);
await
tester
.
pumpWidget
(
buildWidget
(
border:
allowedBorderDirectionalVariations
,
boxShape:
BoxShape
.
circle
));
expect
(
tester
.
takeException
(),
isNull
);
});
});
}
}
This diff is collapsed.
Click to expand it.
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