Home > Back-end >  ( Flutter )How to call setState method of another class?
( Flutter )How to call setState method of another class?

Time:11-08

I want to call the method from another class , i used this approach but method is not calling properly . `


        class PostModel extends StatefulWidget {
          final profilename;
          final bool isVideoUrl;
          final int urlsource;
          final videoUrl;
          const PostModel(
              {this.profilename,
              required this.isVideoUrl,
              required this.urlsource,
              this.videoUrl});
        
          @override
          State<PostModel> createState() => _PostModelState();
        }
        
        class _PostModelState extends State<PostModel> {
          @override
          Widget build(BuildContext context) {
            return Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                NameSection(),
                InkWell(
                  onDoubleTap: , // **toggleLike()** Want to call from here 
                  child: (widget.isVideoUrl)
                      ? SizedBox(
                          width: MediaQuery.of(context).size.width,
                          height: MediaQuery.of(context).size.width,
                          child: VideoController(videosUrl[widget.urlsource % 6]))
                      : Image(
                          image: NetworkImage(
                              "https://picsum.photos/seed/${widget.urlsource}/400/400"),
                          width: MediaQuery.of(context).size.width,
                          fit: BoxFit.cover,
                        ),
                ),
                PostIcons(), // here is the widget .
                Padding(
                    padding: EdgeInsets.symmetric(horizontal: 10),
                    child:
                        Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
                      SizedBox(
                        height: 5,
                      ),
                      Text(
                        "11,536 likes",
                        style: GoogleFonts.roboto(
                            color: Colors.white,
                            fontSize: 12,
                            fontWeight: FontWeight.bold),
                      ),
                      SizedBox(
                        height: 5,
                      ),
                      Text(
                        "akashbanerjee            
  • Related