Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: Cloud_Firestore giving error "FlutterView.send called on a detached view, channel=plugins.flutter.io/cloud_firestore"

I am getting this error every time something changes in FireStore: D/FlutterNativeView(21656): FlutterView.send called on a detached view, channel=plugins.flutter.io/cloud_firestore

And it's happening like 100 times, so I have some sort of memory leak, but I'm getting no details about WHERE this is happening.

I am using something called a StreamBuilder and I suspect that COULD be the culprit. Maybe when I leave the page the StreamBuilder isn't properly being disposed of maybe? Am I supposed to be manually disposing of these in the dispose() method?

I have this:

StreamBuilder<QuerySnapshot> myList = new StreamBuilder<QuerySnapshot>(
  stream: myStream,
  builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot){
});

and I think that when I leave a page, this keeps updating... but can't figure out how to properly dispose of it.

I could also be completely wrong, and it could be from somewhere else, but I really think it's this.

Anyone have any thoughts? I can't post all the code because I can't figure out where it's coming from.

like image 691
Jus10 Avatar asked May 14 '18 23:05

Jus10


1 Answers

I was banging my head against the desk all day trying to figure out the same thing; however, in my particular case if was user error - I had accidentally put a command to pop the page inside of a iterator writing to the DB. So every time I wrote to the DB, it also was popping pages, while also attempting to update the view... Hence, the error.

Might not be the same for you, but carefully look at all of your DB writes to see if you might be doing something with flutter that doesn't make sense in the middle of a DB write.

like image 121
Jason Simpson Avatar answered Oct 22 '22 16:10

Jason Simpson