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
bf602914
Unverified
Commit
bf602914
authored
Dec 15, 2021
by
Dan Field
Committed by
GitHub
Dec 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve sync*/async* opt outs (#95286)
parent
aa599358
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
11 deletions
+32
-11
analyze.dart
dev/bots/analyze.dart
+15
-4
stream_builder.0.dart
examples/api/lib/widgets/async/stream_builder.0.dart
+13
-5
table.dart
packages/flutter/lib/src/rendering/table.dart
+4
-2
No files found.
dev/bots/analyze.dart
View file @
bf602914
...
...
@@ -163,8 +163,8 @@ Future<void> run(List<String> arguments) async {
Future
<
void
>
verifyNoSyncAsyncStar
(
String
workingDirectory
,
{
int
minimumMatches
=
2000
})
async
{
final
RegExp
syncPattern
=
RegExp
(
r'\s*?a?sync\*\s*?{'
);
const
String
ignorePattern
=
'no_sync_async_star'
;
final
RegExp
commentPattern
=
RegExp
(
r'^\s*?//
/?
'
);
final
RegExp
ignorePattern
=
RegExp
(
r'^\s*?// The following uses a?sync\* because:? '
)
;
final
RegExp
commentPattern
=
RegExp
(
r'^\s*?//'
);
final
List
<
String
>
errors
=
<
String
>[];
await
for
(
final
File
file
in
_allFiles
(
workingDirectory
,
'dart'
,
minimumMatches:
minimumMatches
))
{
if
(
file
.
path
.
contains
(
'test'
))
{
...
...
@@ -176,8 +176,19 @@ Future<void> verifyNoSyncAsyncStar(String workingDirectory, {int minimumMatches
if
(
line
.
startsWith
(
commentPattern
))
{
continue
;
}
if
(
line
.
contains
(
syncPattern
)
&&
!
line
.
contains
(
ignorePattern
)
&&
(
index
==
0
||
!
lines
[
index
-
1
].
contains
(
ignorePattern
)))
{
errors
.
add
(
'
${file.path}
:
$index
: sync*/async* without an ignore (no_sync_async_star).'
);
if
(
line
.
contains
(
syncPattern
))
{
int
lookBehindIndex
=
index
-
1
;
bool
hasExplanation
=
false
;
while
(
lookBehindIndex
>=
0
&&
lines
[
lookBehindIndex
].
startsWith
(
commentPattern
))
{
if
(
lines
[
lookBehindIndex
].
startsWith
(
ignorePattern
))
{
hasExplanation
=
true
;
break
;
}
lookBehindIndex
-=
1
;
}
if
(!
hasExplanation
)
{
errors
.
add
(
'
${file.path}
:
$index
: sync*/async* without an explanation.'
);
}
}
}
}
...
...
examples/api/lib/widgets/async/stream_builder.0.dart
View file @
bf602914
...
...
@@ -4,6 +4,8 @@
// Flutter code sample for StreamBuilder
import
'dart:async'
;
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
MyApp
());
...
...
@@ -30,11 +32,17 @@ class MyStatefulWidget extends StatefulWidget {
}
class
_MyStatefulWidgetState
extends
State
<
MyStatefulWidget
>
{
// ignore: no_sync_async_star
final
Stream
<
int
>
_bids
=
(()
async
*
{
await
Future
<
void
>.
delayed
(
const
Duration
(
seconds:
1
));
yield
1
;
await
Future
<
void
>.
delayed
(
const
Duration
(
seconds:
1
));
final
Stream
<
int
>
_bids
=
(()
{
late
final
StreamController
<
int
>
controller
;
controller
=
StreamController
<
int
>(
onListen:
()
async
{
await
Future
<
void
>.
delayed
(
const
Duration
(
seconds:
1
));
controller
.
add
(
1
);
await
Future
<
void
>.
delayed
(
const
Duration
(
seconds:
1
));
await
controller
.
close
();
},
);
return
controller
.
stream
;
})();
@override
...
...
packages/flutter/lib/src/rendering/table.dart
View file @
bf602914
...
...
@@ -795,7 +795,8 @@ class RenderTable extends RenderBox {
/// column, in row order, starting from the first row.
///
/// This is a lazily-evaluated iterable.
// flutter_ignore: no_sync_async_star
// The following uses sync* because it is public API documented to return a
// lazy iterable.
Iterable
<
RenderBox
>
column
(
int
x
)
sync
*
{
for
(
int
y
=
0
;
y
<
rows
;
y
+=
1
)
{
final
int
xy
=
x
+
y
*
columns
;
...
...
@@ -809,7 +810,8 @@ class RenderTable extends RenderBox {
/// row, in column order, starting with the first column.
///
/// This is a lazily-evaluated iterable.
// flutter_ignore: no_sync_async_star
// The following uses sync* because it is public API documented to return a
// lazy iterable.
Iterable
<
RenderBox
>
row
(
int
y
)
sync
*
{
final
int
start
=
y
*
columns
;
final
int
end
=
(
y
+
1
)
*
columns
;
...
...
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