Files
Makoto Sato 10a89e1421 Add audioplayers for elinux (#96)
Signed-off-by: Makoto Sato <makoto.sato@atmark-techno.com>
2024-05-02 10:59:55 +09:00

43 lines
1.1 KiB
Dart

import 'package:audioplayers/audioplayers.dart';
import 'package:audioplayers_elinux_example/components/dlg.dart';
import 'package:flutter/material.dart';
extension StateExt<T extends StatefulWidget> on State<T> {
void toast(String message, {Key? textKey}) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message, key: textKey),
duration: Duration(milliseconds: message.length * 25),
),
);
}
void simpleDialog(String message, [String action = 'Ok']) {
showDialog<void>(
context: context,
builder: (_) {
return SimpleDlg(message: message, action: action);
},
);
}
void dialog(Widget child) {
showDialog<void>(
context: context,
builder: (_) {
return Dlg(child: child);
},
);
}
}
extension PlayerStateIcon on PlayerState {
IconData getIcon() {
return this == PlayerState.playing
? Icons.play_arrow
: (this == PlayerState.paused
? Icons.pause
: (this == PlayerState.stopped ? Icons.stop : Icons.stop_circle));
}
}