Code Monkey home page Code Monkey logo

Comments (6)

jamesblasco avatar jamesblasco commented on August 14, 2024 2

An example of a widget with this mixin

class Counter extends StatefulWidget {
  @override
  _CounterState createState() => _CounterState();
}

class _CounterState extends State<Counter> with AutomaticKeepAliveClientMixin {
  int counter = 0;

  @override
  Widget build(BuildContext context) {
    super.build(context);

    return Material(
      child: InkResponse(
        onTap: () {
          setState(() {
            counter += 1;
          });
        },
        child: Container(
          height: 200,
          width: 200,
          child: Text('$counter'),
        ),
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}

from flutter_staggered_grid_view.

nishanthrk avatar nishanthrk commented on August 14, 2024 1

addAutomaticKeepAlives is true by default to make it work you need to extend AutomaticKeepAliveClientMixin and

@override
bool get wantKeepAlive => true;

@override
  Widget build(BuildContext context) {
    super.build(context);
    return Wiget;
  }

from flutter_staggered_grid_view.

jamesblasco avatar jamesblasco commented on August 14, 2024 1

I tried and @nishanthrk solution work as expected

from flutter_staggered_grid_view.

letsar avatar letsar commented on August 14, 2024

Hi @YoneHsiung,

Can you write a complete solution that I would just have to copy/paste to test it please?
I had to rewrite everything about KeepAlive because of flutter/flutter#19380, and this PR might help me to fix things related to KeepAlives.
I will wait for it to be merged in order to dive deeper in this issue.

from flutter_staggered_grid_view.

jzoom avatar jzoom commented on August 14, 2024

This is what I'am searching for , thank you for your KeepAlive.

from flutter_staggered_grid_view.

JacenWei avatar JacenWei commented on August 14, 2024

@letsar I also encountered the same problem in the process of using it. What should I do? thanks!

from flutter_staggered_grid_view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.