Critical fix for recognition logic to prevent duplicate processing:
1. Problem Identified:
- _recognitionTimer was repeatedly calling decode() on same audio data
- Same recognition results were being sent multiple times to UI
- Caused redundant processing and potential performance issues
2. Solution Implemented:
- Add _lastRecognizedText state variable to track previous results
- Only send recognition results when text content actually changes
- Reset _lastRecognizedText when starting new recording session
3. Logic Changes:
- Enhanced recognition loop with duplicate detection:
A command-line utility for Dart development.
Usage: dart <command|dart-file> [arguments]
Global options:
-v, --verbose Show additional command output.
--version Print the Dart SDK version.
--enable-analytics Enable analytics.
--disable-analytics Disable analytics.
--suppress-analytics Disallow analytics for this `dart *` run without changing the analytics configuration.
-h, --help Print this usage information.
Available commands:
analyze Analyze Dart code in a directory.
compile Compile Dart to various formats.
create Create a new Dart project.
devtools Open DevTools (optionally connecting to an existing application).
doc Generate API documentation for Dart projects.
fix Apply automated fixes to Dart source code.
format Idiomatically format Dart source code.
info Show diagnostic information about the installed tooling.
pub Work with packages.
run Run a Dart program.
test Run tests for a project.
Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
- Added debug logging for skipped duplicate results
- Reset state on startListening() to ensure clean slate
4. Benefits:
- Eliminates duplicate recognition results sent to UI
- Reduces unnecessary computation and network overhead
- Improves user experience with cleaner, non-repetitive updates
- Better resource utilization and battery life
This fix addresses the core issue where the recognition timer was
processing the same audio stream content repeatedly, ensuring each
unique recognition result is only sent once to the application.
Major design changes based on user requirements:
1. Background Style Changes:
- Remove solid color background and shadows
- Use semi-transparent background (alpha: 0.12) for subtle visual feedback
- Maintain circular shape for both states
2. Icon Improvements:
- Increase icon size to 55% of button size for better visibility
- Use color-coded icons: blue for idle, red for recording
- Remove white icon color, use theme-based colors instead
3. Loading Indicator Enhancement:
- Show CircularProgressIndicator during both processing and listening states
- Position indicator as overlay using Stack layout
- Maintain white color for progress indicator for contrast
4. Color Logic Simplification:
- Consolidate color logic into single iconColor variable
- Remove complex state-based color transitions
- Use consistent color scheme: blue (#2196F3) idle, red (#FF5252) recording
- Darker disabled color (#212121) for better contrast
5. Layout Structure Update:
- Replace Transform.scale animation wrapper with direct Container
- Use Stack for layering icon and progress indicator
- Positioned widgets for precise control over element placement
This creates a more modern, minimalist design with better visual hierarchy
and improved accessibility through higher contrast ratios.
Correction based on user feedback:
- Both idle and recording states use circular shape (BoxShape.circle)
- Remove conditional rectangle shape logic
- Keep color differentiation: blue for idle, red for recording
- Maintain consistent circular InkWell ripple effect
Design now correctly matches the mockup:
🔵 Blue circle (idle/ready to record)
🔴 Red circle (actively recording)
Both buttons maintain the same circular shape with only color changes.
Design improvements based on provided mockup:
1. Color Updates:
- Idle state: Blue (#2196F3) - matches mockup's blue recording button
- Recording state: Red (#FF5252) - matches mockup's red stop button
- Disabled state: Light grey (#9E9E9E) for better visibility
- Processing state: Semi-transparent versions of respective colors
2. Shape Changes:
- Idle state: Circle (for recording button)
- Recording state: Rounded rectangle (12px radius) for stop button
- Smooth transitions between shapes using BoxShape
3. Icon Improvements:
- Use rounded icons (mic_rounded, stop_rounded) for modern look
- Adjust icon sizes: recording (40% of button), stop (35% of button)
- Better proportions matching the design intent
4. Shadow Enhancements:
- Increased blur radius for idle state (8→12px) for better depth
- Dynamic shadow based on button state
- Enhanced spread radius for better visual impact
5. Interactive Elements:
- InkWell borderRadius adapts to button shape
- Smooth transitions between circular and rectangular ripple effects
These changes create a modern, professional appearance that matches
common design patterns and provides clear visual feedback for different states.
Major UX improvements to RecordingButton:
1. Haptic Feedback (震动效果):
- Add HapticFeedback.lightImpact() on button tap
- Import flutter/services.dart for haptic support
- Provides tactile confirmation for user interactions
2. Debounce Mechanism (防抖):
- Add _isProcessing flag to prevent rapid consecutive taps
- 300ms cooldown period after each tap
- Protects against accidental double-taps and ensures stable operation
3. Enhanced Visual States:
- Processing state with semi-transparent color
- Loading spinner during async operations
- Better visual feedback for different button states
4. Improved Animations:
- Trigger scale animation on tap (not just on state change)
- Smooth forward/reverse animation cycle
- Better visual response to user interactions
5. Better Error Handling:
- Proper mounted check before setState
- Graceful cleanup with finally block
- Prevents memory leaks and state corruption
These improvements provide:
- Better tactile feedback for users
- Prevention of UI race conditions
- Clearer visual indication of button states
- More responsive and professional user experience
Major SDK simplification by removing redundant final result processing:
1. YxAsrService changes:
- Remove final result retrieval in stopListening()
- Remove finalResult parameter from _sendResult()
- Simplify stop logic to only reset stream state
- Eliminate duplicate API calls that provided no additional value
2. SpeechRecognitionResult model changes:
- Remove finalResult property and related logic
- Update constructor, factory methods, toString, equals, hashCode
- Remove finalResult from toMap/fromMap serialization
- Simplify the model to focus on actual recognition data
3. Benefits:
- Cleaner, more maintainable codebase
- Reduced complexity and potential bugs
- Better performance (no redundant API calls)
- Simpler API for developers to use
- Real-time text appending works seamlessly without artificial distinctions
The analysis showed that 'final results' were identical to the last real-time result,
making the distinction unnecessary. Now all results are treated uniformly as
real-time updates, providing a smoother and more intuitive user experience.
1. Add finalResult property to SpeechRecognitionResult class
- Distinguish between real-time and final recognition results
- Update factory methods, toString, equals, and hashCode
- Update toMap and fromMap methods
2. Update YxAsrService to support finalResult flag
- Add finalResult parameter to _sendResult method
- Mark final results with finalResult: true
- Keep real-time results as finalResult: false (default)
3. Remove unused methods to clean up codebase
- Remove unused _toggleRecording method
- Remove unused _updateTextController method
- Clean up orphaned comments
These fixes resolve linter errors and ensure proper text appending functionality.