PlatformException on starting recorder with flutter_sound - flutter

This is my code:
import 'package:audio_session/audio_session.dart';
import 'package:flutter/material.dart';
import 'package:flutter_sound/flutter_sound.dart';
import 'package:flutter_sound_platform_interface/flutter_sound_recorder_platform_interface.dart';
import 'package:path_provider/path_provider.dart';
class MicTest {
static FlutterSoundRecorder? _mRecorder = FlutterSoundRecorder();
static Codec _codec = Codec.aacMP4;
static const theSource = AudioSource.microphone;
static void startRecorder() async {
await _mRecorder!.openRecorder();
final session = await AudioSession.instance;
await session.configure(AudioSessionConfiguration(
avAudioSessionCategory: AVAudioSessionCategory.playAndRecord,
avAudioSessionCategoryOptions:
AVAudioSessionCategoryOptions.allowBluetooth |
AVAudioSessionCategoryOptions.defaultToSpeaker,
avAudioSessionMode: AVAudioSessionMode.spokenAudio,
avAudioSessionRouteSharingPolicy:
AVAudioSessionRouteSharingPolicy.defaultPolicy,
avAudioSessionSetActiveOptions: AVAudioSessionSetActiveOptions.none,
androidAudioAttributes: const AndroidAudioAttributes(
contentType: AndroidAudioContentType.speech,
flags: AndroidAudioFlags.none,
usage: AndroidAudioUsage.voiceCommunication,
),
androidAudioFocusGainType: AndroidAudioFocusGainType.gain,
androidWillPauseWhenDucked: true,
));
print("initialized");
String _mPath = 'tau_file.mp4';
var tempPath = await getTemporaryDirectory();
_mPath = tempPath.path + "/" + _mPath;
_mRecorder!
.startRecorder(
toFile: _mPath,
codec: _codec,
audioSource: theSource,
)
.then((value) {
//setState(() {});
});
}
static void stopRecorder() async {
await _mRecorder!.stopRecorder().then((value) {
// setState(() {
// //var url = value;
// _mplaybackReady = true;
// });
});
}
}
When I call MicTest.startRecorder() I get:
I/flutter ( 6616): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): │ #0 new FlutterSoundRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:140:13)
I/flutter ( 6616): │ #1 MicrophoneUtils._mRecorder (package:myapp/utils/mic_test.dart:9:45)
I/flutter ( 6616): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 6616): │ 🐛 ctor: FlutterSoundRecorder()
I/flutter ( 6616): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): │ #0 FlutterSoundRecorder.openRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:372:13)
I/flutter ( 6616): │ #1 MicrophoneUtils.startRecorder (package:myapp/utils/mic_test.dart:16:23)
I/flutter ( 6616): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 6616): │ 🐛 FS:---> openAudioSession
I/flutter ( 6616): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): │ #0 FlutterSoundRecorder._openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:381:13)
I/flutter ( 6616): │ #1 FlutterSoundRecorder.openRecorder.<anonymous closure> (package:flutter_sound/public/flutter_sound_recorder.dart:374:17)
I/flutter ( 6616): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 6616): │ 🐛 ---> openAudioSession
I/flutter ( 6616): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): │ #0 FlutterSoundRecorder._openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:396:17)
I/flutter ( 6616): │ #1 FlutterSoundRecorder.openRecorder.<anonymous closure> (package:flutter_sound/public/flutter_sound_recorder.dart:374:17)
I/flutter ( 6616): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 6616): │ 🐛 Resetting flutter_sound Recorder Plugin
I/flutter ( 6616): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
E/MediaRecorder( 6616): resume called in an invalid state: 1
E/MediaRecorder( 6616): stop called in an invalid state: 1
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): Failed to handle method call
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): java.lang.IllegalStateException: Reply already submitted
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:430)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:267)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at com.dooboolab.fluttersound.FlutterSoundManager.resetPlugin(FlutterSoundManager.java:88)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at com.dooboolab.fluttersound.FlutterSoundRecorderManager.onMethodCall(FlutterSoundRecorderManager.java:70)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at android.os.Looper.loop(Looper.java:223)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 6616): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/DartMessenger( 6616): Uncaught exception in binary message listener
E/DartMessenger( 6616): java.lang.IllegalStateException: Reply already submitted
E/DartMessenger( 6616): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:430)
E/DartMessenger( 6616): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:282)
E/DartMessenger( 6616): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/DartMessenger( 6616): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/DartMessenger( 6616): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/DartMessenger( 6616): at android.os.Handler.handleCallback(Handler.java:938)
E/DartMessenger( 6616): at android.os.Handler.dispatchMessage(Handler.java:99)
E/DartMessenger( 6616): at android.os.Looper.loop(Looper.java:223)
E/DartMessenger( 6616): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/DartMessenger( 6616): at java.lang.reflect.Method.invoke(Native Method)
E/DartMessenger( 6616): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/DartMessenger( 6616): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/flutter ( 6616): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): │ #0 FlutterSoundRecorder.openRecorderCompleted (package:flutter_sound/public/flutter_sound_recorder.dart:171:13)
I/flutter ( 6616): │ #1 MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:98:22)
I/flutter ( 6616): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 6616): │ 🐛 ---> openRecorderCompleted: true
I/flutter ( 6616): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): │ #0 FlutterSoundRecorder.openRecorderCompleted (package:flutter_sound/public/flutter_sound_recorder.dart:182:13)
I/flutter ( 6616): │ #1 MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:98:22)
I/flutter ( 6616): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 6616): │ 🐛 <--- openRecorderCompleted: true
I/flutter ( 6616): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): │ #0 FlutterSoundRecorder._openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:412:13)
I/flutter ( 6616): │ #1 <asynchronous suspension>
I/flutter ( 6616): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 6616): │ 🐛 <--- openAudioSession
I/flutter ( 6616): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): │ #0 FlutterSoundRecorder.openRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:376:13)
I/flutter ( 6616): │ #1 <asynchronous suspension>
I/flutter ( 6616): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 6616): │ 🐛 FS:<--- openAudioSession
I/flutter ( 6616): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): initialized
I/flutter ( 6616): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): │ #0 FlutterSoundRecorder.startRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:590:13)
I/flutter ( 6616): │ #1 MicrophoneUtils.startRecorder (package:myapp/utils/mic_test.dart:40:10)
I/flutter ( 6616): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 6616): │ 🐛 FS:---> startRecorder
I/flutter ( 6616): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 6616): │ #0 FlutterSoundRecorder._startRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:614:13)
I/flutter ( 6616): │ #1 FlutterSoundRecorder.startRecorder.<anonymous closure> (package:flutter_sound/public/flutter_sound_recorder.dart:592:13)
I/flutter ( 6616): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 6616): │ 🐛 FS:---> _startRecorder.
I/flutter ( 6616): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
E/flutter ( 6616): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(startRecorder, startRecorder, Failure to start recorder, null)
E/flutter ( 6616): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter ( 6616): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter ( 6616): <asynchronous suspension>
E/flutter ( 6616): #2 FlutterSoundRecorder._startRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:671:7)
E/flutter ( 6616): <asynchronous suspension>
E/flutter ( 6616): #3 FlutterSoundRecorder.startRecorder.<anonymous closure> (package:flutter_sound/public/flutter_sound_recorder.dart:592:7)
E/flutter ( 6616): <asynchronous suspension>
E/flutter ( 6616): #4 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
E/flutter ( 6616): <asynchronous suspension>
E/flutter ( 6616): #5 FlutterSoundRecorder.startRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:591:5)
E/flutter ( 6616): <asynchronous suspension>
E/flutter ( 6616):
I've just started using flutter_sound, so I think the problem is in my code. Could anyone say how to fix this problem?

Related

Unhandled Exception: Instance of '_RecorderRunningException' flutter_sound_lite

I am using flutter sound lite library what I wanna do is to record the sound and then play the recorded sound so i wrote the following code
importing the library
import 'package:flutter_sound_lite/public/flutter_sound_recorder.dart';
Class to record the sound start_recorder.dart
class SoundRecorder{
FlutterSoundRecorder? _audioRecorder;
bool _isRecorderInitialised= false;
bool isRecording=false;
//init method
Future init() async{
_audioRecorder= FlutterSoundRecorder();
final status= await Permission.microphone.request();
if(status!= PermissionStatus.granted){
throw RecordingPermissionException('Microphone permission not granted');
}
await _audioRecorder!.openAudioSession();
_isRecorderInitialised=true;
}
//dispose method
void dispose(){
if(!_isRecorderInitialised) return;
_audioRecorder!.closeAudioSession();
_audioRecorder=null;
_isRecorderInitialised=false;
}
//record method to record sound
Future _record() async{
if(!_isRecorderInitialised) return;
try{
await _audioRecorder!.startRecorder(toFile:pathToSaveAudio );
}
catch (e)
{
throw e;
}
}
//stop method to stop recording sound
Future _stop() async {
if(!_isRecorderInitialised) return;
await _audioRecorder!. startRecorder();
}
Future toggleRecording() async{
if(_audioRecorder!.isStopped){
isRecording=true;
await _record();
}
else{
isRecording=false;
await _stop();
}
}
}
Main.dart
now in main state elevatedButton is a child of a container
Container(
child: ElevatedButton.icon(
style: ElevatedButton.styleFrom(
minimumSize: Size(175, 50),
primary: primary,
onPrimary: onPrimary
),
icon: Icon(icon),
label: Text(
text,
style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold),
),
onPressed: () async{
final isRecording= await recorder.toggleRecording();
setState(() {
});
},
),
)
when i start recorder it turn button red and icon to stop icon but when i click back it doesnt get into actual position and in log it gives an error
Unhandled Exception: Instance of '_RecorderRunningException'
logs
V/AutofillManager(26337): requestHideFillUi(null): anchor = null
I/flutter (26337): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (26337): │ #0 FlutterSoundRecorder.startRecorder (package:flutter_sound_lite/public/flutter_sound_recorder.dart:635:13)
I/flutter (26337): │ #1 SoundRecorder._record (package:speech_app/api/start_recorder.dart:27:29)
I/flutter (26337): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (26337): │ 🐛 FS:---> startRecorder
I/flutter (26337): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (26337): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (26337): │ #0 FlutterSoundRecorder._startRecorder (package:flutter_sound_lite/public/flutter_sound_recorder.dart:659:13)
I/flutter (26337): │ #1 FlutterSoundRecorder.startRecorder.<anonymous closure> (package:flutter_sound_lite/public/flutter_sound_recorder.dart:637:13)
I/flutter (26337): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (26337): │ 🐛 FS:---> _startRecorder.
I/flutter (26337): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
D/AudioRecordExtImpl(26337): AudioRecordExtImpl init
D/AudioRecordExtImpl(26337): audiorecordTest
D/AudioRecord(26337): set(): inputSource 0, sampleRate 16000, format 0x1, channelMask 0x10, frameCount 1280, notificationFrames 0, sessionId 0, transferType 0, flags 0, identity AttributionSourceState{pid: -1, uid: 10375, packageName: com.speech.app.speech_app, attributionTag: (null), token: , renouncedPermissions: [], next: []}uid -1, pid -1
D/AudioRecord(26337): set(): mSessionId 0
D/AudioRecord(26337): start(2854): sync event 0 trigger session 0
I/System.out(26337): ---> writeAudioDataToFile
W/System.err(26337): java.io.FileNotFoundException: audio_example.wav: open failed: EROFS (Read-only file system)
W/System.err(26337): at libcore.io.IoBridge.open(IoBridge.java:574)
W/System.err(26337): at java.io.FileOutputStream.<init>(FileOutputStream.java:236)
W/System.err(26337): at java.io.FileOutputStream.<init>(FileOutputStream.java:125)
W/System.err(26337): at com.dooboolab.TauEngine.FlautoRecorderEngine.writeAudioDataToFile(FlautoRecorderEngine.java:70)
W/System.err(26337): at com.dooboolab.TauEngine.FlautoRecorderEngine._startRecorder(FlautoRecorderEngine.java:247)
W/System.err(26337): at com.dooboolab.TauEngine.FlautoRecorder.startRecorder(FlautoRecorder.java:300)
W/System.err(26337): at com.dooboolab.fluttersound.FlutterSoundRecorder.startRecorder(FlutterSoundRecorder.java:261)
W/System.err(26337): at com.dooboolab.fluttersound.FlutterSoundRecorderManager.onMethodCall(FlutterSoundRecorderManager.java:106)
W/System.err(26337): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
W/System.err(26337): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
W/System.err(26337): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
W/System.err(26337): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
W/System.err(26337): at android.os.Handler.handleCallback(Handler.java:938)
W/System.err(26337): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(26337): at android.os.Looper.loopOnce(Looper.java:233)
W/System.err(26337): at android.os.Looper.loop(Looper.java:344)
W/System.err(26337): at android.app.ActivityThread.main(ActivityThread.java:8212)
W/System.err(26337): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(26337): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
W/System.err(26337): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)
W/System.err(26337): Caused by: android.system.ErrnoException: open failed: EROFS (Read-only file system)
W/System.err(26337): at libcore.io.Linux.open(Native Method)
W/System.err(26337): at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
W/System.err(26337): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
W/System.err(26337): at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
W/System.err(26337): at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8094)
W/System.err(26337): at libcore.io.IoBridge.open(IoBridge.java:560)
W/System.err(26337): ... 19 more
I/flutter (26337): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (26337): │ #0 FlutterSoundRecorder.startRecorderCompleted (package:flutter_sound_lite/public/flutter_sound_recorder.dart:249:13)
I/flutter (26337): │ #1 MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:74:22)
I/flutter (26337): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (26337): │ 🐛 ---> startRecorderCompleted: true
I/flutter (26337): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (26337): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (26337): │ #0 FlutterSoundRecorder.startRecorderCompleted (package:flutter_sound_lite/public/flutter_sound_recorder.dart:258:13)
I/flutter (26337): │ #1 MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:74:22)
I/flutter (26337): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (26337): │ 🐛 <--- startRecorderCompleted: true
I/flutter (26337): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (26337): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (26337): │ #0 FlutterSoundRecorder._startRecorder (package:flutter_sound_lite/public/flutter_sound_recorder.dart:750:13)
I/flutter (26337): │ #1 <asynchronous suspension>
I/flutter (26337): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (26337): │ 🐛 FS:<--- _startRecorder.
I/flutter (26337): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (26337): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (26337): │ #0 FlutterSoundRecorder.startRecorder (package:flutter_sound_lite/public/flutter_sound_recorder.dart:647:13)
I/flutter (26337): │ #1 <asynchronous suspension>
I/flutter (26337): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (26337): │ 🐛 FS:<--- startRecorder
I/flutter (26337): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

DioError [DioErrorType.response]: Http status error [504]

There's an error in my flutter app DioError [DioErrorType.response]: Http status error [504] I don't know why it shows 504 as what I know before, 504 means Gateway Timeout, why it took a long time to respond eventhough it shows the correct response in postman. It ended up with showing "error" in my app's user interface (UI) and my console is look like this:
I/flutter (16822): DioError [DioErrorType.response]: Http status error [504]
I/flutter (16822): Source stack:
I/flutter (16822): #0 DioMixin.fetch (package:dio/src/dio_mixin.dart:488:35)
I/flutter (16822): #1 DioMixin.request (package:dio/src/dio_mixin.dart:483:12)
I/flutter (16822): #2 DioMixin.get (package:dio/src/dio_mixin.dart:61:12)
I/flutter (16822): #3 ApiWrapper.request (package:eoffice/utils/networks/ApiWrapper.dart:66:38)
I/flutter (16822): <asynchronous suspension>
I/flutter (16822): #4 SimpegService.apiRequest (package:eoffice/utils/networks/constans/SimpegService.dart:34:16)
I/flutter (16822): <asynchronous suspension>
I/flutter (16822): #5 LeaveListRepository.fetchResponse (package:eoffice/modules/home/views/widgets/Dashboard/DashboardApp/Leave/LeaveList/repositories/LeaveListRepository.dart:14:9)
I/flutter (16822): <asynchronous suspension>
I/flutter (16822): #6 LeaveListBloc.fetchResponse (package:eoffice/modules/home/views/widgets/Dashboard/DashboardApp/Leave/LeaveList/blocs/LeaveListBloc.dart:33:11)
I/flutter (16822): <asynchronous suspension>
D/EGL_emulation(16822): app_time_stats: avg=62.44ms min=6.19ms max=130.16ms count=15
I/flutter (16822): DioError [DioErrorType.response]: Http status error [504]
I/flutter (16822): Source stack:
I/flutter (16822): #0 DioMixin.fetch (package:dio/src/dio_mixin.dart:488:35)
I/flutter (16822): #1 DioMixin.request (package:dio/src/dio_mixin.dart:483:12)
I/flutter (16822): #2 DioMixin.get (package:dio/src/dio_mixin.dart:61:12)
I/flutter (16822): #3 ApiWrapper.request (package:eoffice/utils/networks/ApiWrapper.dart:66:38)
I/flutter (16822): <asynchronous suspension>
I/flutter (16822): #4 SimpegService.apiRequest (package:eoffice/utils/networks/constans/SimpegService.dart:34:16)
I/flutter (16822): <asynchronous suspension>
I/flutter (16822): #5 LeaveListRepository.fetchResponse (package:eoffice/modules/home/views/widgets/Dashboard/DashboardApp/Leave/LeaveList/repositories/LeaveListRepository.dart:14:9)
I/flutter (16822): <asynchronous suspension>
I/flutter (16822): #6 LeaveListBloc.fetchResponse (package:eoffice/modules/home/views/widgets/Dashboard/DashboardApp/Leave/LeaveList/blocs/LeaveListBloc.dart:33:11)
I/flutter (16822): <asynchronous suspension>
are you using a device or emulator? if emulator, when you fetch you must use 10.0.2.2 as localhost. For device use the ip4 in cmd ipconfig.

Exception after flutter create

I'm new to Flutter,
Right after creating my second app:
flutter create myapp && cd myapp && flutter run
I'm getting this exception. And although the app with the simple counter works in emulator, this exception doesn't look healthy, right?
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
I/flutter ( 6000): ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 6000): The following assertion was thrown during a scheduler callback:
I/flutter ( 6000): There are multiple heroes that share the same tag within a subtree.
I/flutter ( 6000): Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), each Hero must
I/flutter ( 6000): have a unique non-null tag.
I/flutter ( 6000): In this case, multiple heroes had the following tag: <default FloatingActionButton tag>
...
(package:flutter/src/scheduler/binding.dart:1102:15)
I/flutter ( 6000): #141 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1049:9)
I/flutter ( 6000): #142 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:957:5)
I/flutter ( 6000): #146 _invoke (dart:ui/hooks.dart:259:10)
I/flutter ( 6000): #147 _drawFrame (dart:ui/hooks.dart:217:3)
I/flutter ( 6000): (elided 3 frames from package dart:async)
I/flutter ( 6000): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 6000): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter ( 6000): The following NetworkImageLoadException was thrown resolving an image codec:
I/flutter ( 6000): HTTP request failed, statusCode: 403,
I/flutter ( 6000): https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg
I/flutter ( 6000):
I/flutter ( 6000): When the exception was thrown, this was the stack:
I/flutter ( 6000): #0 NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:90:9)
I/flutter ( 6000): <asynchronous suspension>
I/flutter ( 6000): #1 NetworkImage.load (package:flutter/src/painting/_network_image_io.dart:47:14)
I/flutter ( 6000): #2 ImageProvider.resolve.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:327:17)
I/flutter ( 6000): #3 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:160:22)
...
(package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #213 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #214 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #215 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #216 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #217 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #218 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #219 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #220 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #221 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:163:11)
I/flutter ( 6000): #222 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:477:7)
I/flutter ( 6000): #223 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:232:7)
I/flutter ( 6000): #224 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:391:14)
I/flutter ( 6000): #225 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1584:7)
I/flutter ( 6000): #226 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:844:18)
I/flutter ( 6000): #227 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:344:19)
I/flutter ( 6000): #228 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:774:13)
I/flutter ( 6000): #229 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:283:5)
I/flutter ( 6000): #230 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1102:15)
I/flutter ( 6000): #231 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1041:9)
I/flutter ( 6000): #232 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:957:5)
I/flutter ( 6000): #236 _invoke (dart:ui/hooks.dart:259:10)
I/flutter ( 6000): #237 _drawFrame (dart:ui/hooks.dart:217:3)
I/flutter ( 6000): (elided 6 frames from package dart:async)
I/flutter ( 6000):
I/flutter ( 6000): Image provider:
I/flutter ( 6000): NetworkImage("https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg", scale:
I/flutter ( 6000): 1.0)
I/flutter ( 6000): Image key: NetworkImage("https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg",
I/flutter ( 6000): scale: 1.0)
I/flutter ( 6000): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 6000): Another exception was thrown: There are multiple heroes that share the same tag within a subtree.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 26.5s
✓ Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk... 8.8s
Syncing files to device Android SDK built for x86...
10,951ms (!)
Do you have any idea why? Thanks!
The starter Flutter app doesn't contain things like loading network images as it's just a simple counter app. As Vijaya said, it's probably just an old error from another project. I get the same stuff when I use flutter run. Unless you edited the flutter create template, you have nothing to worry about.

Get PlatformException(exception, Unknown signInOption, null) with Google Signin Flutter

I am trying to use the signInWithGoogle method from Auth package.
https://pub.dev/packages/auth
I have the following exception and stack trace.
I/flutter (20513): Caught: PlatformException(exception, Unknown signInOption, null)
I/flutter (20513): Stack: #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
I/flutter (20513): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
I/flutter (20513): <asynchronous suspension>
I/flutter (20513): #2 MethodChannelGoogleSignIn.init (package:google_sign_in_platform_interface/src/method_channel_google_sign_in.dart:26:20)
I/flutter (20513): #3 GoogleSignIn._ensureInitialized (package:google_sign_in/google_sign_in.dart:228:62)
I/flutter (20513): #4 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:210:11)
I/flutter (20513): <asynchronous suspension>
I/flutter (20513): #5 GoogleSignIn._addMethodCall (package:google_sign_in/google_sign_in.dart:266:18)
I/flutter (20513): <asynchronous suspension>
I/flutter (20513): #6 GoogleSignIn.signIn (package:google_sign_in/google_sign_in.dart:336:9)
I/flutter (20513): #7 Auth.signInWithGoogle (package:auth/auth.dart:686:43)
I/flutter (20513): #8 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
I/flutter (20513): #9 Auth.signInWithGoogle (package:auth/auth.dart:674:32)
I/flutter (20513): #10 _LoginPageState.build.<anonymous closure> (package:betting_ai/l
Here is the gist that I use:
https://gist.github.com/deadsoul44/f95c72c3d7a3529d4ac2efce751a3866
Any idea how to solve this issue?

Flutter: navigate to another screen from inside of StreamBuilder builder callback

I have a splash screen and a StreamBuilder that emits a state that contains information about authentication status. When the authentication status is known, I want to navigate either to sign in page or home page. But when I write something like Navigator.of(context).pushReplacement(...) I get
I/flutter ( 2058): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 2058): The following assertion was thrown building StreamBuilder(dirty, state:
I/flutter ( 2058): _StreamBuilderBaseState>#f4346):
I/flutter ( 2058): setState() or markNeedsBuild() called during build.
I/flutter ( 2058): This Overlay widget cannot be marked as needing to build because the framework is already in the
I/flutter ( 2058): process of building widgets. A widget can be marked as needing to be built during the build phase
I/flutter ( 2058): only if one of its ancestors is currently building. This exception is allowed because the framework
I/flutter ( 2058): builds parent widgets before children, which means a dirty descendant will always be built.
I/flutter ( 2058): Otherwise, the framework might not visit this widget during this build phase.
I/flutter ( 2058): The widget on which setState() or markNeedsBuild() was called was:
I/flutter ( 2058): Overlay-[LabeledGlobalKey#e0460](state: OverlayState#ab1a5(entries:
I/flutter ( 2058): [OverlayEntry#4e962(opaque: false; maintainState: false), OverlayEntry#7656a(opaque: false;
I/flutter ( 2058): maintainState: true), OverlayEntry#1f86e(opaque: false; maintainState: false),
I/flutter ( 2058): OverlayEntry#05a15(opaque: false; maintainState: true)]))
I/flutter ( 2058): The widget which was currently being built when the offending call was made was:
I/flutter ( 2058): StreamBuilder(dirty, state: _StreamBuilderBaseState>#f4346)
I/flutter ( 2058):
I/flutter ( 2058): When the exception was thrown, this was the stack:
I/flutter ( 2058): #0 Element.markNeedsBuild. (package:flutter/src/widgets/framework.dart:3503:11)
I/flutter ( 2058): #1 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:3529:6)
I/flutter ( 2058): #2 State.setState (package:flutter/src/widgets/framework.dart:1133:14)
I/flutter ( 2058): #3 OverlayState.insertAll (package:flutter/src/widgets/overlay.dart:346:5)
I/flutter ( 2058): #4 OverlayRoute.install (package:flutter/src/widgets/routes.dart:43:24)
I/flutter ( 2058): #5 TransitionRoute.install (package:flutter/src/widgets/routes.dart:180:11)
I/flutter ( 2058): #6 ModalRoute.install (package:flutter/src/widgets/routes.dart:895:11)
I/flutter ( 2058): #7 NavigatorState.pushReplacement (package:flutter/src/widgets/navigator.dart:1799:14)
I/flutter ( 2058): #8 _replace (package:map_chat/application/navigation.dart:75:27)
I/flutter ( 2058): #9 _SignInPage.replace (package:map_chat/application/navigation.dart:67:5)
I/flutter ( 2058): #10 Roadmap.replace (package:map_chat/application/navigation.dart:25:18)
I/flutter ( 2058): #11 _SplashPageState._buildPageBasedOnAuthenticationState (package:map_chat/feature/splash.dart:52:19)
I/flutter ( 2058): #12 _SplashPageState._buildSplashScreen (package:map_chat/feature/splash.dart:40:11)
I/flutter ( 2058): #13 _SplashPageState._buildPage. (package:map_chat/feature/splash.dart:27:18)
I/flutter ( 2058): #14 StreamBuilder.build (package:flutter/src/widgets/async.dart:425:74)
I/flutter ( 2058): #15 _StreamBuilderBaseState.build (package:flutter/src/widgets/async.dart:125:48)
I/flutter ( 2058): #16 StatefulElement.build (package:flutter/src/widgets/framework.dart:3825:27)
I/flutter ( 2058): #17 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3739:15)
I/flutter ( 2058): #18 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 2058): #19 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2278:33)
I/flutter ( 2058): #20 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20)
I/flutter ( 2058): #21 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:286:5)
I/flutter ( 2058): #22 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1012:15)
I/flutter ( 2058): #23 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:952:9)
I/flutter ( 2058): #24 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame. (package:flutter/src/scheduler/binding.dart:773:7)
I/flutter ( 2058): #33 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
I/flutter ( 2058): #34 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
I/flutter ( 2058): #35 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)
I/flutter ( 2058): (elided 8 frames from package dart:async and package dart:async-patch)
The only workaround I found is to schedule the navigation to the end of event queue using Future(...).then(navigate) but that's sick. Is here an adequate solution for this?
You can listen your stream outside of build method and redirect to another view from there.
---- EDITED ----
This is an example of how you can do that:
#override
void initState() {
super.initState();
Future.delayed(Duration.zero, _verify);
}
void _verify() {
final _myBloc = BlocProvider.getBloc<MyBloc>();
_myBloc.myStream.listen((data) {
// Redirect to another view, given your condition
if (data) {
Navigator.of(context).pushNamed("my-new-route");
}
});
}
Just remember to save the StreamSubscription object returned from listen method, so you can cancel the subscription on dispose().
I still not happy with my solution, but I use a
if(snapshot.hasdata && snapshot.data.navigate) {
Future.microtask(() => Navigator.of(context).push... );
}