我在我的代码中添加了服务以将文本作为声音读取,但在发布模式下它不起作用 我尝试添加一些权限,如 internet 和 record_audio,但它也不起作用 我希望你能帮助我
这是我的代码
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class ReadQuoteButton extends StatefulWidget {
final String text;
final Color color;
ReadQuoteButton(this.text,this.color);
@override
_ReadQuoteButtonState createState() => _ReadQuoteButtonState();
}
class _ReadQuoteButtonState extends State<ReadQuoteButton> {
static const platform = const MethodChannel('flutter.dev/awspolly');
@override
Widget build(BuildContext context) {
return IconButton(
icon: Icon(
Icons.volume_up,
size: 32,
color: widget.color,
),
onPressed: () {
readQuote(widget.text);
});
}
void readQuote(String textQuote) async {
try {
await platform.invokeMethod('readQuote', {'textQuote': textQuote});
} catch (e) {
print(e);
}
}
}