Skip to content

Commit

Permalink
refactor: Adapt to flame_lint v0.2.0+2 (#1477)
Browse files Browse the repository at this point in the history
Adapt code to comply with new lint rules published in `flame_lint` v0.2.0+2
  • Loading branch information
Gustl22 authored Apr 18, 2023
1 parent 61d4c39 commit e1d7fb6
Show file tree
Hide file tree
Showing 24 changed files with 104 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ Duration? _parseDuration(String? s) {
if (s == null || s.isEmpty) {
return null;
}
var hours = 0, minutes = 0, micros = 0;
var hours = 0;
var minutes = 0;
var micros = 0;
final parts = s.split(':');
if (parts.length > 2) {
hours = int.parse(parts[parts.length - 3]);
Expand Down
6 changes: 5 additions & 1 deletion packages/audioplayers/example/lib/components/btn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ class Btn extends StatelessWidget {
final String txt;
final VoidCallback onPressed;

const Btn({super.key, required this.txt, required this.onPressed});
const Btn({
required this.txt,
required this.onPressed,
super.key,
});

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion packages/audioplayers/example/lib/components/cbx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class Cbx extends StatelessWidget {

const Cbx(
this.label,
this.value,
this.update, {
required this.value,
super.key,
});

Expand Down
7 changes: 4 additions & 3 deletions packages/audioplayers/example/lib/components/dlg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import 'package:audioplayers_example/components/btn.dart';
import 'package:flutter/material.dart';

class SimpleDlg extends StatelessWidget {
final String message, action;
final String message;
final String action;

const SimpleDlg({
super.key,
required this.message,
required this.action,
super.key,
});

@override
Expand All @@ -31,8 +32,8 @@ class Dlg extends StatelessWidget {
final Widget child;

const Dlg({
super.key,
required this.child,
super.key,
});

@override
Expand Down
4 changes: 2 additions & 2 deletions packages/audioplayers/example/lib/components/drop_down.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ class LabeledDropDown<T> extends StatelessWidget {
final void Function(T?) onChange;

const LabeledDropDown({
super.key,
required this.label,
required this.options,
required this.selected,
required this.onChange,
super.key,
});

@override
Expand All @@ -34,11 +34,11 @@ class CustomDropDown<T> extends StatelessWidget {
final bool isExpanded;

const CustomDropDown({
super.key,
required this.options,
required this.selected,
required this.onChange,
this.isExpanded = false,
super.key,
});

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class WrappedListTile extends StatelessWidget {
final Widget? trailing;

const WrappedListTile({
super.key,
required this.children,
this.leading,
this.trailing,
super.key,
});

@override
Expand Down
3 changes: 2 additions & 1 deletion packages/audioplayers/example/lib/components/pad.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:flutter/material.dart';

class Pad extends StatelessWidget {
final double width, height;
final double width;
final double height;

const Pad({super.key, this.width = 0, this.height = 0});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import 'package:flutter/material.dart';
class PlayerWidget extends StatefulWidget {
final AudioPlayer player;

const PlayerWidget({super.key, required this.player});
const PlayerWidget({
required this.player,
super.key,
});

@override
State<StatefulWidget> createState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import 'package:flutter/material.dart';
class PropertiesWidget extends StatefulWidget {
final AudioPlayer player;

const PropertiesWidget({super.key, required this.player});
const PropertiesWidget({
required this.player,
super.key,
});

@override
State<PropertiesWidget> createState() => _PropertiesWidgetState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import 'package:flutter/material.dart';
class StreamWidget extends StatefulWidget {
final AudioPlayer player;

const StreamWidget({super.key, required this.player});
const StreamWidget({
required this.player,
super.key,
});

@override
State<StreamWidget> createState() => _StreamWidgetState();
}

class _StreamWidgetState extends State<StreamWidget> {
Duration? streamDuration, streamPosition;
Duration? streamDuration;
Duration? streamPosition;
PlayerState? streamState;
late List<StreamSubscription> streams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import 'package:flutter/material.dart';
class TabContent extends StatelessWidget {
final List<Widget> children;

const TabContent({super.key, required this.children});
const TabContent({
required this.children,
super.key,
});

@override
Widget build(BuildContext context) {
Expand Down
11 changes: 9 additions & 2 deletions packages/audioplayers/example/lib/components/tabs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import 'package:flutter/material.dart';
class Tabs extends StatelessWidget {
final List<TabData> tabs;

const Tabs({super.key, required this.tabs});
const Tabs({
required this.tabs,
super.key,
});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -41,5 +44,9 @@ class TabData {
final String label;
final Widget content;

TabData({this.key, required this.label, required this.content});
TabData({
required this.label,
required this.content,
this.key,
});
}
4 changes: 2 additions & 2 deletions packages/audioplayers/example/lib/components/tgl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class Tgl extends StatelessWidget {
final void Function(int) onChange;

const Tgl({
super.key,
required this.options,
required this.selected,
required this.onChange,
super.key,
});

@override
Expand Down Expand Up @@ -43,10 +43,10 @@ class EnumTgl<T extends Enum> extends StatelessWidget {
final void Function(T) onChange;

const EnumTgl({
super.key,
required this.options,
required this.selected,
required this.onChange,
super.key,
});

@override
Expand Down
3 changes: 2 additions & 1 deletion packages/audioplayers/example/lib/components/txt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import 'package:flutter/material.dart';
class TxtBox extends StatefulWidget {
final String value;
final void Function(String) onChange;

const TxtBox({
super.key,
required this.value,
required this.onChange,
super.key,
});

@override
Expand Down
8 changes: 4 additions & 4 deletions packages/audioplayers/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ const defaultPlayerCount = 4;
typedef OnError = void Function(Exception exception);

void main() {
runApp(const MaterialApp(home: ExampleApp()));
runApp(const MaterialApp(home: _ExampleApp()));
}

class ExampleApp extends StatefulWidget {
const ExampleApp({super.key});
class _ExampleApp extends StatefulWidget {
const _ExampleApp();

@override
_ExampleAppState createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
class _ExampleAppState extends State<_ExampleApp> {
List<AudioPlayer> audioPlayers = List.generate(
defaultPlayerCount,
(_) => AudioPlayer()..setReleaseMode(ReleaseMode.stop),
Expand Down
23 changes: 13 additions & 10 deletions packages/audioplayers/example/lib/tabs/audio_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import 'package:flutter/material.dart';
class AudioContextTab extends StatefulWidget {
final AudioPlayer player;

const AudioContextTab({super.key, required this.player});
const AudioContextTab({
required this.player,
super.key,
});

@override
_AudioContextTabState createState() => _AudioContextTabState();
AudioContextTabState createState() => AudioContextTabState();
}

class _AudioContextTabState extends State<AudioContextTab>
class AudioContextTabState extends State<AudioContextTab>
with AutomaticKeepAliveClientMixin<AudioContextTab> {
static GlobalAudioScope get _global => AudioPlayer.global;

Expand Down Expand Up @@ -102,22 +105,22 @@ class _AudioContextTabState extends State<AudioContextTab>
children: [
Cbx(
'Force Speaker',
audioContextConfig.forceSpeaker,
value: audioContextConfig.forceSpeaker,
(v) => updateConfig(audioContextConfig.copy(forceSpeaker: v)),
),
Cbx(
'Duck Audio',
audioContextConfig.duckAudio,
value: audioContextConfig.duckAudio,
(v) => updateConfig(audioContextConfig.copy(duckAudio: v)),
),
Cbx(
'Respect Silence',
audioContextConfig.respectSilence,
value: audioContextConfig.respectSilence,
(v) => updateConfig(audioContextConfig.copy(respectSilence: v)),
),
Cbx(
'Stay Awake',
audioContextConfig.stayAwake,
value: audioContextConfig.stayAwake,
(v) => updateConfig(audioContextConfig.copy(stayAwake: v)),
),
],
Expand All @@ -129,14 +132,14 @@ class _AudioContextTabState extends State<AudioContextTab>
children: [
Cbx(
'isSpeakerphoneOn',
audioContext.android.isSpeakerphoneOn,
value: audioContext.android.isSpeakerphoneOn,
(v) => updateAudioContextAndroid(
audioContext.android.copy(isSpeakerphoneOn: v),
),
),
Cbx(
'stayAwake',
audioContext.android.stayAwake,
value: audioContext.android.stayAwake,
(v) => updateAudioContextAndroid(
audioContext.android.copy(stayAwake: v),
),
Expand Down Expand Up @@ -187,7 +190,7 @@ class _AudioContextTabState extends State<AudioContextTab>
final options = audioContext.iOS.options.toList();
return Cbx(
option.name,
options.contains(option),
value: options.contains(option),
(v) {
if (v) {
options.add(option);
Expand Down
7 changes: 5 additions & 2 deletions packages/audioplayers/example/lib/tabs/controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import 'package:flutter/material.dart';
class ControlsTab extends StatefulWidget {
final AudioPlayer player;

const ControlsTab({super.key, required this.player});
const ControlsTab({
required this.player,
super.key,
});

@override
State<ControlsTab> createState() => _ControlsTabState();
Expand Down Expand Up @@ -188,11 +191,11 @@ class SeekDialog extends StatelessWidget {
final String value;

const SeekDialog({
super.key,
required this.seekDuration,
required this.seekPercent,
required this.value,
required this.setValue,
super.key,
});

@override
Expand Down
11 changes: 7 additions & 4 deletions packages/audioplayers/example/lib/tabs/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import 'package:flutter/material.dart';
class LoggerTab extends StatefulWidget {
final AudioPlayer player;

const LoggerTab({super.key, required this.player});
const LoggerTab({
required this.player,
super.key,
});

@override
_LoggerTabState createState() => _LoggerTabState();
LoggerTabState createState() => LoggerTabState();
}

class _LoggerTabState extends State<LoggerTab>
class LoggerTabState extends State<LoggerTab>
with AutomaticKeepAliveClientMixin<LoggerTab> {
AudioLogLevel get currentLogLevel => AudioLogger.logLevel;

Expand Down Expand Up @@ -132,10 +135,10 @@ class LogView extends StatelessWidget {
final VoidCallback onDelete;

const LogView({
super.key,
required this.logs,
required this.title,
required this.onDelete,
super.key,
});

@override
Expand Down
5 changes: 4 additions & 1 deletion packages/audioplayers/example/lib/tabs/sources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const invalidAsset = 'invalid.txt';
class SourcesTab extends StatefulWidget {
final AudioPlayer player;

const SourcesTab({super.key, required this.player});
const SourcesTab({
required this.player,
super.key,
});

@override
State<SourcesTab> createState() => _SourcesTabState();
Expand Down
Loading

0 comments on commit e1d7fb6

Please sign in to comment.