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:
@@ -9,19 +9,18 @@ class LocalAudioTrack extends AudioTrack {
|
||||
: super(name, track, stream);
|
||||
|
||||
/// Creates a new audio track from the default audio input device.
|
||||
static Future<LocalAudioTrack> createTrack(
|
||||
[LocalAudioTrackOptions? options]) async {
|
||||
static Future<LocalAudioTrack> createTrack([LocalAudioTrackOptions? options]) async {
|
||||
try {
|
||||
var stream = await navigator.mediaDevices.getUserMedia({
|
||||
"audio": true,
|
||||
"video": false,
|
||||
final stream = await navigator.mediaDevices.getUserMedia(<String, dynamic>{
|
||||
'audio': true,
|
||||
'video': false,
|
||||
});
|
||||
|
||||
if (stream.getAudioTracks().length == 0) {
|
||||
if (stream.getAudioTracks().isEmpty) {
|
||||
return Future.error(TrackCreateError());
|
||||
}
|
||||
|
||||
return LocalAudioTrack("", stream.getAudioTracks().first, stream);
|
||||
return LocalAudioTrack('', stream.getAudioTracks().first, stream);
|
||||
} catch (e) {
|
||||
return Future.error(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user