skip to Main Content

i am creating a connection between my flutter application and firebase but when the time came to use the dispose function it is not defined

i’ve added the package as a library to the flutter and dart

dart pub add dispose
flutter pub add dispose

then i import the package in my class using :

import 'package:dispose/dispose.dart';

but nothing happedned also and the functon still undefined
the packages that i’ve added

2

Answers


  1. Did you mean to use this instead?

    @override
    void dispose() {
      yourStream.cancel(); //Cancel your subscription here.
      super.dispose();
    }
    
    Login or Signup to reply.
  2. The dispose() method is only available in Stateful widgets, convert your widget into a Stateful widget and it should let you use it as normal. This is always required if you use Controllers or Listeners to properly dispose them.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search