Skip to content

Commit 770ab28

Browse files
committed
Add more rigorous analysis options.
1 parent acb906b commit 770ab28

32 files changed

+463
-377
lines changed

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
* [iOS] Use MrAlek Libyuv pod fixing incompatibility with FirebaseFirestore.
3737
* [iOS] Upgrade GoogleWebRTC dependency to 1.1.29400.
3838

39-
4039
[0.2.6] - 2020.02.03
4140

4241
* Fixed the interruption of the Bluetooth headset that was playing music after the plugin started.

analysis_options.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -1 +1,46 @@
11
include: package:pedantic/analysis_options.yaml
2+
3+
linter:
4+
rules:
5+
- always_declare_return_types
6+
- avoid_empty_else
7+
- await_only_futures
8+
- avoid_returning_null_for_void
9+
- cancel_subscriptions
10+
- directives_ordering
11+
- flutter_style_todos
12+
- sort_constructors_first
13+
- sort_unnamed_constructors_first
14+
- sort_pub_dependencies
15+
- type_init_formals
16+
- unnecessary_brace_in_string_interps
17+
- unnecessary_const
18+
- unnecessary_new
19+
- unnecessary_getters_setters
20+
- unnecessary_null_aware_assignments
21+
- unnecessary_null_in_if_null_operators
22+
- unnecessary_overrides
23+
- unnecessary_parenthesis
24+
- unnecessary_statements
25+
- unnecessary_string_interpolations
26+
- unnecessary_this
27+
- unrelated_type_equality_checks
28+
- use_rethrow_when_possible
29+
- valid_regexps
30+
- void_checks
31+
32+
analyzer:
33+
errors:
34+
# treat missing required parameters as a warning (not a hint)
35+
missing_required_param: warning
36+
# treat missing returns as a warning (not a hint)
37+
missing_return: warning
38+
# allow having TODOs in the code
39+
todo: ignore
40+
# allow self-reference to deprecated members (we do this because otherwise we have
41+
# to annotate every member in every test, assert, etc, when we deprecate something)
42+
deprecated_member_use_from_same_package: ignore
43+
# Ignore analyzer hints for updating pubspecs when using Future or
44+
# Stream and not importing dart:async
45+
# Please see https://github.com/flutter/flutter/pull/24528 for details.
46+
sdk_version_async_exported_from_core: ignore

example/analysis_options.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
include: package:pedantic/analysis_options.yaml
2+
3+
linter:
4+
rules:
5+
- always_declare_return_types
6+
- avoid_empty_else
7+
- await_only_futures
8+
- avoid_returning_null_for_void
9+
- cancel_subscriptions
10+
- directives_ordering
11+
- flutter_style_todos
12+
- sort_constructors_first
13+
- sort_unnamed_constructors_first
14+
- sort_pub_dependencies
15+
- type_init_formals
16+
- unnecessary_brace_in_string_interps
17+
- unnecessary_const
18+
- unnecessary_new
19+
- unnecessary_getters_setters
20+
- unnecessary_null_aware_assignments
21+
- unnecessary_null_in_if_null_operators
22+
- unnecessary_overrides
23+
- unnecessary_parenthesis
24+
- unnecessary_statements
25+
- unnecessary_string_interpolations
26+
- unnecessary_this
27+
- unrelated_type_equality_checks
28+
- use_rethrow_when_possible
29+
- valid_regexps
30+
- void_checks
31+
32+
analyzer:
33+
errors:
34+
# treat missing required parameters as a warning (not a hint)
35+
missing_required_param: warning
36+
# treat missing returns as a warning (not a hint)
37+
missing_return: warning
38+
# allow having TODOs in the code
39+
todo: ignore
40+
# allow self-reference to deprecated members (we do this because otherwise we have
41+
# to annotate every member in every test, assert, etc, when we deprecate something)
42+
deprecated_member_use_from_same_package: ignore
43+
# Ignore analyzer hints for updating pubspecs when using Future or
44+
# Stream and not importing dart:async
45+
# Please see https://github.com/flutter/flutter/pull/24528 for details.
46+
sdk_version_async_exported_from_core: ignore

example/lib/main.dart

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
import 'dart:core';
2-
import 'package:flutter/material.dart';
2+
33
import 'package:flutter/foundation.dart'
44
show debugDefaultTargetPlatformOverride;
5+
import 'package:flutter/material.dart';
56
import 'package:flutter_webrtc/webrtc.dart';
67

7-
import 'src/loopback_sample.dart';
8+
import 'src/data_channel_sample.dart';
9+
import 'src/get_display_media_sample.dart';
810
import 'src/get_user_media_sample.dart'
911
if (dart.library.js) 'src/get_user_media_sample_web.dart';
10-
import 'src/get_display_media_sample.dart';
11-
import 'src/data_channel_sample.dart';
12+
import 'src/loopback_sample.dart';
1213
import 'src/route_item.dart';
1314

1415
void main() {
15-
if (WebRTC.platformIsDesktop)
16+
if (WebRTC.platformIsDesktop) {
1617
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
17-
runApp(new MyApp());
18+
}
19+
runApp(MyApp());
1820
}
1921

2022
class MyApp extends StatefulWidget {
2123
@override
22-
_MyAppState createState() => new _MyAppState();
24+
_MyAppState createState() => _MyAppState();
2325
}
2426

2527
class _MyAppState extends State<MyApp> {
2628
List<RouteItem> items;
2729

2830
@override
29-
initState() {
31+
void initState() {
3032
super.initState();
3133
_initItems();
3234
}
3335

34-
_buildRow(context, item) {
36+
ListBody _buildRow(context, item) {
3537
return ListBody(children: <Widget>[
3638
ListTile(
3739
title: Text(item.title),
@@ -44,12 +46,12 @@ class _MyAppState extends State<MyApp> {
4446

4547
@override
4648
Widget build(BuildContext context) {
47-
return new MaterialApp(
48-
home: new Scaffold(
49-
appBar: new AppBar(
50-
title: new Text('Flutter-WebRTC example'),
49+
return MaterialApp(
50+
home: Scaffold(
51+
appBar: AppBar(
52+
title: Text('Flutter-WebRTC example'),
5153
),
52-
body: new ListView.builder(
54+
body: ListView.builder(
5355
shrinkWrap: true,
5456
padding: const EdgeInsets.all(0.0),
5557
itemCount: items.length,
@@ -59,42 +61,40 @@ class _MyAppState extends State<MyApp> {
5961
);
6062
}
6163

62-
_initItems() {
64+
void _initItems() {
6365
items = <RouteItem>[
6466
RouteItem(
6567
title: 'GetUserMedia',
6668
push: (BuildContext context) {
6769
Navigator.push(
6870
context,
69-
new MaterialPageRoute(
70-
builder: (BuildContext context) =>
71-
new GetUserMediaSample()));
71+
MaterialPageRoute(
72+
builder: (BuildContext context) => GetUserMediaSample()));
7273
}),
7374
RouteItem(
7475
title: 'GetDisplayMedia',
7576
push: (BuildContext context) {
7677
Navigator.push(
7778
context,
78-
new MaterialPageRoute(
79+
MaterialPageRoute(
7980
builder: (BuildContext context) =>
80-
new GetDisplayMediaSample()));
81+
GetDisplayMediaSample()));
8182
}),
8283
RouteItem(
8384
title: 'LoopBack Sample',
8485
push: (BuildContext context) {
8586
Navigator.push(
8687
context,
87-
new MaterialPageRoute(
88-
builder: (BuildContext context) => new LoopBackSample()));
88+
MaterialPageRoute(
89+
builder: (BuildContext context) => LoopBackSample()));
8990
}),
9091
RouteItem(
9192
title: 'DataChannel',
9293
push: (BuildContext context) {
9394
Navigator.push(
9495
context,
95-
new MaterialPageRoute(
96-
builder: (BuildContext context) =>
97-
new DataChannelSample()));
96+
MaterialPageRoute(
97+
builder: (BuildContext context) => DataChannelSample()));
9898
}),
9999
];
100100
}

example/lib/src/data_channel_sample.dart

+36-37
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import 'dart:core';
12
import 'dart:typed_data';
23

34
import 'package:flutter/material.dart';
45
import 'package:flutter_webrtc/webrtc.dart';
5-
import 'dart:core';
66

77
class DataChannelSample extends StatefulWidget {
88
static String tag = 'data_channel_sample';
99

1010
@override
11-
_DataChannelSampleState createState() => new _DataChannelSampleState();
11+
_DataChannelSampleState createState() => _DataChannelSampleState();
1212
}
1313

1414
class _DataChannelSampleState extends State<DataChannelSample> {
@@ -21,23 +21,23 @@ class _DataChannelSampleState extends State<DataChannelSample> {
2121
String _sdp;
2222

2323
@override
24-
initState() {
24+
void initState() {
2525
super.initState();
2626
}
2727

28-
_onSignalingState(RTCSignalingState state) {
28+
void _onSignalingState(RTCSignalingState state) {
2929
print(state);
3030
}
3131

32-
_onIceGatheringState(RTCIceGatheringState state) {
32+
void _onIceGatheringState(RTCIceGatheringState state) {
3333
print(state);
3434
}
3535

36-
_onIceConnectionState(RTCIceConnectionState state) {
36+
void _onIceConnectionState(RTCIceConnectionState state) {
3737
print(state);
3838
}
3939

40-
_onCandidate(RTCIceCandidate candidate) {
40+
void _onCandidate(RTCIceCandidate candidate) {
4141
print('onCandidate: ' + candidate.candidate);
4242
_peerConnection.addCandidate(candidate);
4343
setState(() {
@@ -46,12 +46,12 @@ class _DataChannelSampleState extends State<DataChannelSample> {
4646
});
4747
}
4848

49-
_onRenegotiationNeeded() {
49+
void _onRenegotiationNeeded() {
5050
print('RenegotiationNeeded');
5151
}
5252

5353
/// Send some sample messages and handle incoming messages.
54-
_onDataChannel(RTCDataChannel dataChannel) {
54+
void _onDataChannel(RTCDataChannel dataChannel) {
5555
dataChannel.onMessage = (message) {
5656
if (message.type == MessageType.text) {
5757
print(message.text);
@@ -68,30 +68,30 @@ class _DataChannelSampleState extends State<DataChannelSample> {
6868
}
6969
});
7070

71-
dataChannel.send(RTCDataChannelMessage("Hello!"));
71+
dataChannel.send(RTCDataChannelMessage('Hello!'));
7272
dataChannel.send(RTCDataChannelMessage.fromBinary(Uint8List(5)));
7373
}
7474

7575
// Platform messages are asynchronous, so we initialize in an async method.
76-
_makeCall() async {
77-
Map<String, dynamic> configuration = {
78-
"iceServers": [
79-
{"url": "stun:stun.l.google.com:19302"},
76+
void _makeCall() async {
77+
var configuration = <String, dynamic>{
78+
'iceServers': [
79+
{'url': 'stun:stun.l.google.com:19302'},
8080
]
8181
};
8282

83-
final Map<String, dynamic> offerSdpConstraints = {
84-
"mandatory": {
85-
"OfferToReceiveAudio": false,
86-
"OfferToReceiveVideo": false,
83+
final offerSdpConstraints = <String, dynamic>{
84+
'mandatory': {
85+
'OfferToReceiveAudio': false,
86+
'OfferToReceiveVideo': false,
8787
},
88-
"optional": [],
88+
'optional': [],
8989
};
9090

91-
final Map<String, dynamic> loopbackConstraints = {
92-
"mandatory": {},
93-
"optional": [
94-
{"DtlsSrtpKeyAgreement": true},
91+
final loopbackConstraints = <String, dynamic>{
92+
'mandatory': {},
93+
'optional': [
94+
{'DtlsSrtpKeyAgreement': true},
9595
],
9696
};
9797

@@ -107,22 +107,21 @@ class _DataChannelSampleState extends State<DataChannelSample> {
107107
_peerConnection.onIceCandidate = _onCandidate;
108108
_peerConnection.onRenegotiationNeeded = _onRenegotiationNeeded;
109109

110-
_dataChannelDict = new RTCDataChannelInit();
110+
_dataChannelDict = RTCDataChannelInit();
111111
_dataChannelDict.id = 1;
112112
_dataChannelDict.ordered = true;
113113
_dataChannelDict.maxRetransmitTime = -1;
114114
_dataChannelDict.maxRetransmits = -1;
115-
_dataChannelDict.protocol = "sctp";
115+
_dataChannelDict.protocol = 'sctp';
116116
_dataChannelDict.negotiated = false;
117117

118118
_dataChannel = await _peerConnection.createDataChannel(
119119
'dataChannel', _dataChannelDict);
120120
_peerConnection.onDataChannel = _onDataChannel;
121121

122-
RTCSessionDescription description =
123-
await _peerConnection.createOffer(offerSdpConstraints);
122+
var description = await _peerConnection.createOffer(offerSdpConstraints);
124123
print(description.sdp);
125-
_peerConnection.setLocalDescription(description);
124+
await _peerConnection.setLocalDescription(description);
126125

127126
_sdp = description.sdp;
128127
//change for loopback.
@@ -138,7 +137,7 @@ class _DataChannelSampleState extends State<DataChannelSample> {
138137
});
139138
}
140139

141-
_hangUp() async {
140+
void _hangUp() async {
142141
try {
143142
await _dataChannel.close();
144143
await _peerConnection.close();
@@ -153,23 +152,23 @@ class _DataChannelSampleState extends State<DataChannelSample> {
153152

154153
@override
155154
Widget build(BuildContext context) {
156-
return new Scaffold(
157-
appBar: new AppBar(
158-
title: new Text('Data Channel Test'),
155+
return Scaffold(
156+
appBar: AppBar(
157+
title: Text('Data Channel Test'),
159158
),
160-
body: new OrientationBuilder(
159+
body: OrientationBuilder(
161160
builder: (context, orientation) {
162-
return new Center(
163-
child: new Container(
161+
return Center(
162+
child: Container(
164163
child: _inCalling ? Text(_sdp) : Text('data channel test'),
165164
),
166165
);
167166
},
168167
),
169-
floatingActionButton: new FloatingActionButton(
168+
floatingActionButton: FloatingActionButton(
170169
onPressed: _inCalling ? _hangUp : _makeCall,
171170
tooltip: _inCalling ? 'Hangup' : 'Call',
172-
child: new Icon(_inCalling ? Icons.call_end : Icons.phone),
171+
child: Icon(_inCalling ? Icons.call_end : Icons.phone),
173172
),
174173
);
175174
}

0 commit comments

Comments
 (0)