Flutter: Getting out of memory error. Unable to put the dispose function in the proper location

I am using a video player to play the videos I get from my stream builder. I am unable to place my dispose function in such a way that I don’t get this error.

Error is causing the emulator to crash after a certain point.What I tried:

  1. I placed the dispose after initializing the video player but has not worked because I am initializing the video player again.
  2. I tried putting in the build function of stream builder too but it does not work

My screen where I am getting this error:

class _PageViewBuilderState extends State<PageViewBuilder> {
  VideoPlayerController? INvideoPlayerController;
  void initState() {
    INvideoPlayerController = VideoPlayerController.network('')
      ..addListener(() {})
      ..initialize().then((value) => INvideoPlayerController!.play());

  void dispose() {

  int _currentPage = 0;
  Widget build(BuildContext context) {
    return Scaffold(
      body: StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
          builder: (ctx, snapshot) {
            if (snapshot.hasError) {
              const Center(
                child: Text('Unknown Error'),

            return !snapshot.hasData
                ? const Center(
                    child: CircularProgressIndicator(),
                : PageView.builder(
                    scrollDirection: Axis.vertical,
                    itemCount: snapshot.data!.docs.length,
                    onPageChanged: (int page) {
                      setState(() {
                        _currentPage = page;
                    itemBuilder: (BuildContext context, int index) {
                      INvideoPlayerController = VideoPlayerController.network(
                            .then((value) => INvideoPlayerController!.play());
                      return Stack(alignment: Alignment.center, children: [
                          aspectRatio: MediaQuery.of(context).size.width /
                          //  INvideoPlayerController!.value.aspectRatio,
                          child: VideoPlayer(INvideoPlayerController!),

I am trying to load videos from my firestore storage on the app.