VoiceRecordButton class

长按录音按钮。

类似微信的语音输入交互:长按开始录音,松开自动识别。

用法:

VoiceRecordButton(
  themeColor: Theme.of(context).primaryColor,
  onResult: (text) => print('识别结果: $text'),
)
Inheritance

Constructors

VoiceRecordButton({Key? key, dynamic onResult(String)?, dynamic onPartialResult(String)?, dynamic onRecordingStateChanged(bool)?, dynamic onError(String)?, Color? themeColor, double size = 64, int maxDuration = 10, bool showDuration = true, bool showRipple = true, bool enableHaptic = true, IconData? icon, bool useGlobalService = true})
const

Properties

enableHaptic bool
是否启用触感反馈。
final
hashCode int
The hash code for this object.
no setterinherited
icon IconData?
自定义按钮图标。
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxDuration int
最大录音时长(秒)。
final
onError → dynamic Function(String)?
错误回调。
final
onPartialResult → dynamic Function(String)?
实时识别结果回调。
final
onRecordingStateChanged → dynamic Function(bool)?
录音状态变化回调。
final
onResult → dynamic Function(String)?
识别结果回调。
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showDuration bool
是否显示录音时长。
final
showRipple bool
是否显示波纹动画。
final
size double
按钮大小。
final
themeColor Color?
按钮主题色。
final
useGlobalService bool
是否使用全局服务(推荐开启)。
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<VoiceRecordButton>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited