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
12ceaefb
Unverified
Commit
12ceaefb
authored
Feb 02, 2018
by
Alexandre Ardhuin
Committed by
GitHub
Feb 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work around const lints (#14416)
* work around const lints * update nonconst doc
parent
08823595
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
63 additions
and
54 deletions
+63
-54
archive_publisher.dart
dev/tools/lib/archive_publisher.dart
+1
-1
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+1
-2
alignment_test.dart
packages/flutter/test/painting/alignment_test.dart
+1
-2
border_rtl_test.dart
packages/flutter/test/painting/border_rtl_test.dart
+5
-6
border_side_test.dart
packages/flutter/test/painting/border_side_test.dart
+4
-7
border_test.dart
packages/flutter/test/painting/border_test.dart
+4
-5
colors_test.dart
packages/flutter/test/painting/colors_test.dart
+1
-1
edge_insets_test.dart
packages/flutter/test/painting/edge_insets_test.dart
+1
-1
image_provider_test.dart
packages/flutter/test/painting/image_provider_test.dart
+1
-2
text_span_test.dart
packages/flutter/test/painting/text_span_test.dart
+5
-7
directionality_test.dart
packages/flutter/test/widgets/directionality_test.dart
+1
-2
key_test.dart
packages/flutter/test/widgets/key_test.dart
+11
-14
render_object_widget_test.dart
packages/flutter/test/widgets/render_object_widget_test.dart
+3
-4
flutter_test.dart
packages/flutter_test/lib/flutter_test.dart
+1
-0
nonconst.dart
packages/flutter_test/lib/src/nonconst.dart
+23
-0
No files found.
dev/tools/lib/archive_publisher.dart
View file @
12ceaefb
...
@@ -143,7 +143,7 @@ class ArchivePublisher {
...
@@ -143,7 +143,7 @@ class ArchivePublisher {
jsonData
[
'releases'
][
revision
]
=
metadata
;
jsonData
[
'releases'
][
revision
]
=
metadata
;
final
Directory
localTempDir
=
tempDir
??
Directory
.
systemTemp
.
createTempSync
(
'flutter_'
);
final
Directory
localTempDir
=
tempDir
??
Directory
.
systemTemp
.
createTempSync
(
'flutter_'
);
final
File
tempFile
=
new
File
(
path
.
join
(
localTempDir
.
absolute
.
path
,
'releases.json'
));
final
File
tempFile
=
new
File
(
path
.
join
(
localTempDir
.
absolute
.
path
,
'releases.json'
));
final
JsonEncoder
encoder
=
const
JsonEncoder
.
withIndent
(
' '
);
const
JsonEncoder
encoder
=
const
JsonEncoder
.
withIndent
(
' '
);
tempFile
.
writeAsStringSync
(
encoder
.
convert
(
jsonData
));
tempFile
.
writeAsStringSync
(
encoder
.
convert
(
jsonData
));
_cloudCopy
(
tempFile
.
absolute
.
path
,
metadataGsPath
);
_cloudCopy
(
tempFile
.
absolute
.
path
,
metadataGsPath
);
if
(
tempDir
==
null
)
{
if
(
tempDir
==
null
)
{
...
...
packages/flutter/test/material/tabs_test.dart
View file @
12ceaefb
...
@@ -1503,8 +1503,7 @@ void main() {
...
@@ -1503,8 +1503,7 @@ void main() {
});
});
test
(
'illegal constructor combinations'
,
()
{
test
(
'illegal constructor combinations'
,
()
{
final
Widget
$null
=
null
;
expect
(()
=>
new
Tab
(
icon:
nonconst
(
null
)),
throwsAssertionError
);
expect
(()
=>
new
Tab
(
icon:
$null
),
throwsAssertionError
);
expect
(()
=>
new
Tab
(
icon:
new
Container
(),
text:
'foo'
,
child:
new
Container
()),
throwsAssertionError
);
expect
(()
=>
new
Tab
(
icon:
new
Container
(),
text:
'foo'
,
child:
new
Container
()),
throwsAssertionError
);
expect
(()
=>
new
Tab
(
text:
'foo'
,
child:
new
Container
()),
throwsAssertionError
);
expect
(()
=>
new
Tab
(
text:
'foo'
,
child:
new
Container
()),
throwsAssertionError
);
});
});
...
...
packages/flutter/test/painting/alignment_test.dart
View file @
12ceaefb
...
@@ -92,8 +92,7 @@ void main() {
...
@@ -92,8 +92,7 @@ void main() {
expect
(
const
AlignmentDirectional
(
0.0
,
0.0
).
resolve
(
TextDirection
.
rtl
),
const
Alignment
(
0.0
,
0.0
));
expect
(
const
AlignmentDirectional
(
0.0
,
0.0
).
resolve
(
TextDirection
.
rtl
),
const
Alignment
(
0.0
,
0.0
));
expect
(
const
AlignmentDirectional
(
1.0
,
1.0
).
resolve
(
TextDirection
.
ltr
),
const
Alignment
(
1.0
,
1.0
));
expect
(
const
AlignmentDirectional
(
1.0
,
1.0
).
resolve
(
TextDirection
.
ltr
),
const
Alignment
(
1.0
,
1.0
));
expect
(
const
AlignmentDirectional
(
1.0
,
1.0
).
resolve
(
TextDirection
.
rtl
),
const
Alignment
(-
1.0
,
1.0
));
expect
(
const
AlignmentDirectional
(
1.0
,
1.0
).
resolve
(
TextDirection
.
rtl
),
const
Alignment
(-
1.0
,
1.0
));
final
double
$
1
=
1.0
;
// we want these instances to be separate instances so that we're not just checking with a single object
expect
(
new
AlignmentDirectional
(
nonconst
(
1.0
),
2.0
),
new
AlignmentDirectional
(
nonconst
(
1.0
),
2.0
));
expect
(
new
AlignmentDirectional
(
$
1
,
2.0
),
new
AlignmentDirectional
(
$
1
,
2.0
));
expect
(
const
AlignmentDirectional
(
1.0
,
2.0
),
isNot
(
const
AlignmentDirectional
(
2.0
,
1.0
)));
expect
(
const
AlignmentDirectional
(
1.0
,
2.0
),
isNot
(
const
AlignmentDirectional
(
2.0
,
1.0
)));
expect
(
const
AlignmentDirectional
(-
1.0
,
0.0
).
resolve
(
TextDirection
.
ltr
),
expect
(
const
AlignmentDirectional
(-
1.0
,
0.0
).
resolve
(
TextDirection
.
ltr
),
const
AlignmentDirectional
(
1.0
,
0.0
).
resolve
(
TextDirection
.
rtl
));
const
AlignmentDirectional
(
1.0
,
0.0
).
resolve
(
TextDirection
.
rtl
));
...
...
packages/flutter/test/painting/border_rtl_test.dart
View file @
12ceaefb
...
@@ -317,11 +317,10 @@ void main() {
...
@@ -317,11 +317,10 @@ void main() {
});
});
test
(
'BorderDirectional constructor'
,
()
{
test
(
'BorderDirectional constructor'
,
()
{
final
Null
$null
=
null
;
expect
(()
=>
new
BorderDirectional
(
top:
nonconst
(
null
)),
throwsAssertionError
);
expect
(()
=>
new
BorderDirectional
(
top:
$null
),
throwsAssertionError
);
expect
(()
=>
new
BorderDirectional
(
start:
nonconst
(
null
)),
throwsAssertionError
);
expect
(()
=>
new
BorderDirectional
(
start:
$null
),
throwsAssertionError
);
expect
(()
=>
new
BorderDirectional
(
end:
nonconst
(
null
)),
throwsAssertionError
);
expect
(()
=>
new
BorderDirectional
(
end:
$null
),
throwsAssertionError
);
expect
(()
=>
new
BorderDirectional
(
bottom:
nonconst
(
null
)),
throwsAssertionError
);
expect
(()
=>
new
BorderDirectional
(
bottom:
$null
),
throwsAssertionError
);
});
});
test
(
'BorderDirectional.merge'
,
()
{
test
(
'BorderDirectional.merge'
,
()
{
...
@@ -622,7 +621,7 @@ void main() {
...
@@ -622,7 +621,7 @@ void main() {
});
});
test
(
'BorderDirectional hashCode'
,
()
{
test
(
'BorderDirectional hashCode'
,
()
{
final
BorderSide
side
=
const
BorderSide
(
width:
2.0
);
final
BorderSide
side
=
new
BorderSide
(
width:
nonconst
(
2.0
)
);
expect
(
new
BorderDirectional
(
top:
side
).
hashCode
,
new
BorderDirectional
(
top:
side
).
hashCode
);
expect
(
new
BorderDirectional
(
top:
side
).
hashCode
,
new
BorderDirectional
(
top:
side
).
hashCode
);
expect
(
new
BorderDirectional
(
top:
side
).
hashCode
,
isNot
(
new
BorderDirectional
(
bottom:
side
).
hashCode
));
expect
(
new
BorderDirectional
(
top:
side
).
hashCode
,
isNot
(
new
BorderDirectional
(
bottom:
side
).
hashCode
));
});
});
...
...
packages/flutter/test/painting/border_side_test.dart
View file @
12ceaefb
...
@@ -15,13 +15,10 @@ void main() {
...
@@ -15,13 +15,10 @@ void main() {
style:
BorderStyle
.
solid
,
style:
BorderStyle
.
solid
,
),
),
);
);
// so that we can use `new` below, we use these:
expect
(()
=>
new
BorderSide
(
color:
nonconst
(
null
)),
throwsAssertionError
);
final
Null
$null
=
null
;
expect
(()
=>
new
BorderSide
(
width:
nonconst
(
null
)),
throwsAssertionError
);
final
double
$minus1
=
-
1.0
;
expect
(()
=>
new
BorderSide
(
style:
nonconst
(
null
)),
throwsAssertionError
);
expect
(()
=>
new
BorderSide
(
color:
$null
),
throwsAssertionError
);
expect
(()
=>
new
BorderSide
(
width:
nonconst
(-
1.0
)),
throwsAssertionError
);
expect
(()
=>
new
BorderSide
(
width:
$null
),
throwsAssertionError
);
expect
(()
=>
new
BorderSide
(
style:
$null
),
throwsAssertionError
);
expect
(()
=>
new
BorderSide
(
width:
$minus1
),
throwsAssertionError
);
expect
(
expect
(
const
BorderSide
(
width:
-
0.0
),
const
BorderSide
(
width:
-
0.0
),
const
BorderSide
(
const
BorderSide
(
...
...
packages/flutter/test/painting/border_test.dart
View file @
12ceaefb
...
@@ -7,11 +7,10 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -7,11 +7,10 @@ import 'package:flutter_test/flutter_test.dart';
void
main
(
)
{
void
main
(
)
{
test
(
'Border constructor'
,
()
{
test
(
'Border constructor'
,
()
{
final
Null
$null
=
null
;
expect
(()
=>
new
Border
(
left:
nonconst
(
null
)),
throwsAssertionError
);
expect
(()
=>
new
Border
(
left:
$null
),
throwsAssertionError
);
expect
(()
=>
new
Border
(
top:
nonconst
(
null
)),
throwsAssertionError
);
expect
(()
=>
new
Border
(
top:
$null
),
throwsAssertionError
);
expect
(()
=>
new
Border
(
right:
nonconst
(
null
)),
throwsAssertionError
);
expect
(()
=>
new
Border
(
right:
$null
),
throwsAssertionError
);
expect
(()
=>
new
Border
(
bottom:
nonconst
(
null
)),
throwsAssertionError
);
expect
(()
=>
new
Border
(
bottom:
$null
),
throwsAssertionError
);
});
});
test
(
'Border.merge'
,
()
{
test
(
'Border.merge'
,
()
{
...
...
packages/flutter/test/painting/colors_test.dart
View file @
12ceaefb
...
@@ -40,7 +40,7 @@ void main() {
...
@@ -40,7 +40,7 @@ void main() {
});
});
test
(
'ColorSwatch test'
,
()
{
test
(
'ColorSwatch test'
,
()
{
final
int
color
=
0xFF027223
;
final
int
color
=
nonconst
(
0xFF027223
)
;
final
ColorSwatch
<
String
>
greens1
=
new
ColorSwatch
<
String
>(
final
ColorSwatch
<
String
>
greens1
=
new
ColorSwatch
<
String
>(
color
,
const
<
String
,
Color
>{
color
,
const
<
String
,
Color
>{
'2259 C'
:
const
Color
(
0xFF027223
),
'2259 C'
:
const
Color
(
0xFF027223
),
...
...
packages/flutter/test/painting/edge_insets_test.dart
View file @
12ceaefb
...
@@ -73,7 +73,7 @@ void main() {
...
@@ -73,7 +73,7 @@ void main() {
});
});
test
(
'EdgeInsets equality'
,
()
{
test
(
'EdgeInsets equality'
,
()
{
final
double
$
5
=
5.0
;
// we want these instances to be separate instances so that we're not just checking with a single object
final
double
$
5
=
nonconst
(
5.0
);
expect
(
new
EdgeInsetsDirectional
.
only
(
top:
$
5
,
bottom:
7.0
),
new
EdgeInsetsDirectional
.
only
(
top:
$
5
,
bottom:
7.0
));
expect
(
new
EdgeInsetsDirectional
.
only
(
top:
$
5
,
bottom:
7.0
),
new
EdgeInsetsDirectional
.
only
(
top:
$
5
,
bottom:
7.0
));
expect
(
new
EdgeInsets
.
only
(
top:
$
5
,
bottom:
7.0
),
new
EdgeInsetsDirectional
.
only
(
top:
$
5
,
bottom:
7.0
));
expect
(
new
EdgeInsets
.
only
(
top:
$
5
,
bottom:
7.0
),
new
EdgeInsetsDirectional
.
only
(
top:
$
5
,
bottom:
7.0
));
expect
(
new
EdgeInsetsDirectional
.
only
(
top:
$
5
,
bottom:
7.0
),
new
EdgeInsets
.
only
(
top:
$
5
,
bottom:
7.0
));
expect
(
new
EdgeInsetsDirectional
.
only
(
top:
$
5
,
bottom:
7.0
),
new
EdgeInsets
.
only
(
top:
$
5
,
bottom:
7.0
));
...
...
packages/flutter/test/painting/image_provider_test.dart
View file @
12ceaefb
...
@@ -8,8 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -8,8 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void
main
(
)
{
void
main
(
)
{
test
(
'NetworkImage non-null url test'
,
()
{
test
(
'NetworkImage non-null url test'
,
()
{
expect
(()
{
expect
(()
{
final
String
url
=
null
;
// we don't want this instance to be const because otherwise it would throw at compile time.
new
NetworkImage
(
nonconst
(
null
));
new
NetworkImage
(
url
);
},
throwsAssertionError
);
},
throwsAssertionError
);
});
});
}
}
packages/flutter/test/painting/text_span_test.dart
View file @
12ceaefb
...
@@ -3,19 +3,17 @@
...
@@ -3,19 +3,17 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/painting.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:flutter_test/flutter_test.dart'
show
nonconst
;
import
'package:test/test.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
void
main
(
)
{
test
(
'TextSpan equals'
,
()
{
test
(
'TextSpan equals'
,
()
{
final
String
text
=
'a'
;
// we want these instances to be separate instances so that we're not just checking with a single object
final
TextSpan
a1
=
new
TextSpan
(
text:
nonconst
(
'a'
));
final
TextSpan
a1
=
new
TextSpan
(
text:
text
);
final
TextSpan
a2
=
new
TextSpan
(
text:
nonconst
(
'a'
));
final
TextSpan
a2
=
new
TextSpan
(
text:
text
);
final
TextSpan
b1
=
new
TextSpan
(
children:
<
TextSpan
>[
a1
]);
final
TextSpan
b1
=
new
TextSpan
(
children:
<
TextSpan
>[
a1
]);
final
TextSpan
b2
=
new
TextSpan
(
children:
<
TextSpan
>[
a2
]);
final
TextSpan
b2
=
new
TextSpan
(
children:
<
TextSpan
>[
a2
]);
final
String
nullText
=
null
;
// we want these instances to be separate instances so that we're not just checking with a single object
final
TextSpan
c1
=
new
TextSpan
(
text:
nonconst
(
null
));
final
TextSpan
c1
=
new
TextSpan
(
text:
nullText
);
final
TextSpan
c2
=
new
TextSpan
(
text:
nonconst
(
null
));
final
TextSpan
c2
=
new
TextSpan
(
text:
nullText
);
expect
(
a1
==
a2
,
isTrue
);
expect
(
a1
==
a2
,
isTrue
);
expect
(
b1
==
b2
,
isTrue
);
expect
(
b1
==
b2
,
isTrue
);
...
...
packages/flutter/test/widgets/directionality_test.dart
View file @
12ceaefb
...
@@ -65,8 +65,7 @@ void main() {
...
@@ -65,8 +65,7 @@ void main() {
testWidgets
(
'Directionality can
\'
t be null'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Directionality can
\'
t be null'
,
(
WidgetTester
tester
)
async
{
expect
(()
{
expect
(()
{
final
TextDirection
textDirection
=
null
;
// we don't want this instance to be const because otherwise it would throw at compile time.
new
Directionality
(
textDirection:
nonconst
(
null
),
child:
const
Placeholder
());
new
Directionality
(
textDirection:
textDirection
,
child:
const
Placeholder
());
},
throwsAssertionError
);
},
throwsAssertionError
);
});
});
}
}
packages/flutter/test/widgets/key_test.dart
View file @
12ceaefb
...
@@ -19,21 +19,18 @@ class NotEquals {
...
@@ -19,21 +19,18 @@ class NotEquals {
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'Keys'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Keys'
,
(
WidgetTester
tester
)
async
{
final
int
int3
=
3
;
// we want these instances to be separate instances so that we're not just checking with a single object
expect
(
new
ValueKey
<
int
>(
nonconst
(
3
))
==
new
ValueKey
<
int
>(
nonconst
(
3
)),
isTrue
);
expect
(
new
ValueKey
<
int
>(
int3
)
==
new
ValueKey
<
int
>(
int3
),
isTrue
);
expect
(
new
ValueKey
<
num
>(
nonconst
(
3
))
==
new
ValueKey
<
int
>(
nonconst
(
3
)),
isFalse
);
expect
(
new
ValueKey
<
num
>(
int3
)
==
new
ValueKey
<
int
>(
int3
),
isFalse
);
expect
(
new
ValueKey
<
int
>(
nonconst
(
3
))
==
new
ValueKey
<
int
>(
nonconst
(
2
)),
isFalse
);
final
int
int2
=
2
;
// we want these instances to be separate instances so that we're not just checking with a single object
expect
(
new
ValueKey
<
int
>(
int3
)
==
new
ValueKey
<
int
>(
int2
),
isFalse
);
expect
(
const
ValueKey
<
double
>(
double
.
NAN
)
==
const
ValueKey
<
double
>(
double
.
NAN
),
isFalse
);
expect
(
const
ValueKey
<
double
>(
double
.
NAN
)
==
const
ValueKey
<
double
>(
double
.
NAN
),
isFalse
);
final
String
empty
=
''
;
// we want these instances to be separate instances so that we're not just checking with a single object
expect
(
new
Key
(
nonconst
(
''
))
==
new
ValueKey
<
String
>(
nonconst
(
''
)),
isTrue
);
expect
(
new
Key
(
empty
)
==
new
ValueKey
<
String
>(
empty
),
isTrue
);
expect
(
new
ValueKey
<
String
>(
nonconst
(
''
))
==
new
ValueKey
<
String
>(
nonconst
(
''
)),
isTrue
);
expect
(
new
ValueKey
<
String
>(
empty
)
==
new
ValueKey
<
String
>(
empty
),
isTrue
);
expect
(
new
TestValueKey
<
String
>(
nonconst
(
''
))
==
new
ValueKey
<
String
>(
nonconst
(
''
)),
isFalse
);
expect
(
new
TestValueKey
<
String
>(
empty
)
==
new
ValueKey
<
String
>(
empty
),
isFalse
);
expect
(
new
TestValueKey
<
String
>(
nonconst
(
''
))
==
new
TestValueKey
<
String
>(
nonconst
(
''
)),
isTrue
);
expect
(
new
TestValueKey
<
String
>(
empty
)
==
new
TestValueKey
<
String
>(
empty
),
isTrue
);
expect
(
new
ValueKey
<
String
>(
empty
)
==
new
ValueKey
<
dynamic
>(
empty
),
isFalse
);
expect
(
new
ValueKey
<
String
>(
nonconst
(
''
))
==
new
ValueKey
<
dynamic
>(
nonconst
(
''
)
),
isFalse
);
expect
(
new
TestValueKey
<
String
>(
empty
)
==
new
TestValueKey
<
dynamic
>(
empty
),
isFalse
);
expect
(
new
TestValueKey
<
String
>(
nonconst
(
''
))
==
new
TestValueKey
<
dynamic
>(
nonconst
(
''
)
),
isFalse
);
expect
(
new
UniqueKey
()
==
new
UniqueKey
(),
isFalse
);
expect
(
new
UniqueKey
()
==
new
UniqueKey
(),
isFalse
);
final
LocalKey
k
=
new
UniqueKey
();
final
LocalKey
k
=
new
UniqueKey
();
...
@@ -44,11 +41,11 @@ void main() {
...
@@ -44,11 +41,11 @@ void main() {
expect
(
new
ValueKey
<
LocalKey
>(
k
)
==
new
ValueKey
<
UniqueKey
>(
k
),
isFalse
);
expect
(
new
ValueKey
<
LocalKey
>(
k
)
==
new
ValueKey
<
UniqueKey
>(
k
),
isFalse
);
expect
(
new
ObjectKey
(
k
)
==
new
ObjectKey
(
k
),
isTrue
);
expect
(
new
ObjectKey
(
k
)
==
new
ObjectKey
(
k
),
isTrue
);
final
NotEquals
constNotEquals
=
const
NotEquals
();
// we want these instances to be separate instances so that we're not just checking with a single object
final
NotEquals
constNotEquals
=
nonconst
(
const
NotEquals
());
expect
(
new
ValueKey
<
NotEquals
>(
constNotEquals
)
==
new
ValueKey
<
NotEquals
>(
constNotEquals
),
isFalse
);
expect
(
new
ValueKey
<
NotEquals
>(
constNotEquals
)
==
new
ValueKey
<
NotEquals
>(
constNotEquals
),
isFalse
);
expect
(
new
ObjectKey
(
constNotEquals
)
==
new
ObjectKey
(
constNotEquals
),
isTrue
);
expect
(
new
ObjectKey
(
constNotEquals
)
==
new
ObjectKey
(
constNotEquals
),
isTrue
);
final
Object
constObject
=
const
Object
();
// we want these instances to be separate instances so that we're not just checking with a single object
final
Object
constObject
=
nonconst
(
const
Object
());
expect
(
new
ObjectKey
(
constObject
)
==
new
ObjectKey
(
constObject
),
isTrue
);
expect
(
new
ObjectKey
(
constObject
)
==
new
ObjectKey
(
constObject
),
isTrue
);
expect
(
new
ObjectKey
(
new
Object
())
==
new
ObjectKey
(
new
Object
()),
isFalse
);
expect
(
new
ObjectKey
(
new
Object
())
==
new
ObjectKey
(
new
Object
()),
isFalse
);
...
...
packages/flutter/test/widgets/render_object_widget_test.dart
View file @
12ceaefb
...
@@ -6,10 +6,9 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -6,10 +6,9 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
final
Border
nullBorder
=
null
;
// we want these instances to be separate instances so that we're not just checking with a single object
final
BoxDecoration
kBoxDecorationA
=
new
BoxDecoration
(
border:
nonconst
(
null
));
final
BoxDecoration
kBoxDecorationA
=
new
BoxDecoration
(
border:
nullBorder
);
final
BoxDecoration
kBoxDecorationB
=
new
BoxDecoration
(
border:
nonconst
(
null
));
final
BoxDecoration
kBoxDecorationB
=
new
BoxDecoration
(
border:
nullBorder
);
final
BoxDecoration
kBoxDecorationC
=
new
BoxDecoration
(
border:
nonconst
(
null
));
final
BoxDecoration
kBoxDecorationC
=
new
BoxDecoration
(
border:
nullBorder
);
class
TestWidget
extends
StatelessWidget
{
class
TestWidget
extends
StatelessWidget
{
const
TestWidget
({
this
.
child
});
const
TestWidget
({
this
.
child
});
...
...
packages/flutter_test/lib/flutter_test.dart
View file @
12ceaefb
...
@@ -12,6 +12,7 @@ export 'src/binding.dart';
...
@@ -12,6 +12,7 @@ export 'src/binding.dart';
export
'src/controller.dart'
;
export
'src/controller.dart'
;
export
'src/finders.dart'
;
export
'src/finders.dart'
;
export
'src/matchers.dart'
;
export
'src/matchers.dart'
;
export
'src/nonconst.dart'
;
export
'src/stack_manipulation.dart'
;
export
'src/stack_manipulation.dart'
;
export
'src/test_async_utils.dart'
;
export
'src/test_async_utils.dart'
;
export
'src/test_pointer.dart'
;
export
'src/test_pointer.dart'
;
...
...
packages/flutter_test/lib/src/nonconst.dart
0 → 100644
View file @
12ceaefb
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// This function can be used to call a const constructor in such a way as to
/// create a new instance rather than creating the common const instance.
///
/// ```dart
/// class A {
/// const A(this.i);
/// int i;
/// }
///
/// main () {
/// // prevent prefer_const_constructors lint
/// new A(nonconst(null));
///
/// // prevent prefer_const_declarations lint
/// final int $null = nonconst(null);
/// final A a = nonconst(const A(null));
/// }
/// ```
T
nonconst
<
T
>(
T
t
)
=>
t
;
\ No newline at end of file
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