Apply Flutter best practices [Non-Breaking] (#2)

* Add flutter_lints package

* Use key in widget constructors

lint: use_key_in_widget_constructors

* Unnecessary new keyword

lint: unnecessary_new

* Prefer const with constant constructors

* Exclude protobuf files from analyzer

* Private field could be final

* Annotate overridden members

* Use initializing formals when possible

* Don't access members with `this` unless avoiding shadowing

* Prefer is! operator

* Use isEmpty instead of length

* Use collection literals when possible

* Revert comment changes

* Cleaner null testing

* Misc fixes

* Avoid using `forEach` with a function literal

* Prefer `final` over `var` where applicable

* Enforce stricter type-checking

* Ignore VS Code files

* Flutter format

* Prefer using lowerCamelCase for constant names

* flutter format -l 100

* Disable `avoid_print` for examples

* Slight improvements to example

Should solve lint error: no_logic_in_create_state
This commit is contained in:
Hiroshi Horie
2021-08-31 16:35:07 +09:00
committed by GitHub
parent 4a75d78ef9
commit ab31ddabb9
41 changed files with 904 additions and 1228 deletions
+12 -12
View File
@@ -1,6 +1,6 @@
/// Options when creating a LocalVideoTrack.
class LocalVideoTrackOptions {
CameraPosition position = CameraPosition.FRONT;
CameraPosition position = CameraPosition.front;
VideoParameter params;
LocalVideoTrackOptions({
@@ -16,16 +16,16 @@ class LocalVideoTrackOptions {
}
Map<String, dynamic> get mediaConstraints {
return {
"mandatory": params.mediaConstraints,
"facingMode": position == CameraPosition.FRONT ? "user" : "environment",
return <String, dynamic>{
'mandatory': params.mediaConstraints,
'facingMode': position == CameraPosition.front ? 'user' : 'environment',
};
}
}
enum CameraPosition {
FRONT,
BACK,
front,
back,
}
class VideoParameter {
@@ -38,14 +38,14 @@ class VideoParameter {
this.width,
this.height,
this.fps, {
int? bitrate,
}) : this.bitrate = bitrate;
this.bitrate,
});
Map<String, dynamic> get mediaConstraints {
return {
"minWidth": this.width,
"minHeight": this.height,
"minFrameRate": this.fps,
return <String, dynamic>{
'minWidth': width,
'minHeight': height,
'minFrameRate': fps,
};
}
}