Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

local_hero for GridView items #1

Open
jimmy-robert opened this issue Sep 7, 2020 · 12 comments
Open

local_hero for GridView items #1

jimmy-robert opened this issue Sep 7, 2020 · 12 comments

Comments

@jimmy-robert
Copy link

Hello @letsar !

Great package as always 馃憤馃従 I really think this can be a game changer for many use cases.

I can't make it run with GridView items though, do you have any idea why?

Greetings from an former colleague from OAB 馃檪

@letsar
Copy link
Owner

letsar commented Sep 7, 2020

Hi Jimmy 馃檪.
It's probably because of Repaint boundary. Try to set addRepaintBoundaries to false. I will look further later if it's not that.

@letsar
Copy link
Owner

letsar commented Sep 7, 2020

Ok, so that's because the RepaintBoundary as I said, but if your GridView is scrollable, it will not work as you expect. During the scroll, all items will change positions, so they will try to animate, resulting in an ugly user experience 馃槙.

@jimmy-robert
Copy link
Author

Indeed, I wish it worked with ListViews and GridViews, it would have been a great alternative to AnimatedList and (not existing) AnimatedGrid.

Great job though, other than in scrollable views it works like a charm. Already 猸愶笍 the repo.

@letsar
Copy link
Owner

letsar commented Sep 8, 2020

Yeah I didn't designed it to work under scrollable widgets while it could be quite interesting. I don't know how to handle that for the moment but maybe there is a solution.
Thanks for the star 馃槈

@rbozan
Copy link

rbozan commented Sep 12, 2020

Unfortunately that it doesn't work with ListViews and GridViews. I have an user interface where you can switch between a card layout and a list layout, and while the size does transition correctly the position is immediately changed.

Guess I'll just use a Navigator, as that also works for my use case :)

@lukepighetti
Copy link

Stick it in a custom TableGrid and it will work for you.

import 'package:flutter/material.dart';

class TableGrid extends StatelessWidget {
  /// A very simple grid without using scrollable solutions like [GridView]
  const TableGrid({
    Key key,
    this.columns = 2,
    @required this.children,
  }) : super(key: key);

  /// The number of columns to have in the width
  final int columns;

  final List<Widget> children;

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (context, constraints) {
        assert(constraints.hasBoundedWidth);
        final width = constraints.maxWidth;

        return Wrap(
          children: [
            for (var child in children)
              SizedBox(
                width: width / columns,
                child: child,
              ),
          ],
        );
      },
    );
  }
}

@TJMusiitwa
Copy link

@letsar Do you think this solution by @lukepighetti is similar enough in practicality to the flutter_sidekick SidekickTeamBuilder.
Because that implementation is just what I would need for the project I am working on and seems local_hero might be lacking something of the sort.

Maybe you could point to an example solution or advise on whether I should fork flutter_sidekick, converting to null_safety before using in my project?
Thanks

@MarazMia
Copy link

Can anyone give me one example code that works on grid?

@lukepighetti
Copy link

@TDuffinNTU
Copy link

Bumping this, I'd love to see scrollable views working with this plugin! I wanted to use it for my notes app (which would use a grid cards to show previews of the saved notes) but couldn't get this to work since I'd need a scrolling view :(

I hope you come back to give this some love soon!

@abdelaziz-mahdy
Copy link

Bumping this, I'd love to see scrollable views working with this plugin! I wanted to use it for my notes app (which would use a grid cards to show previews of the saved notes) but couldn't get this to work since I'd need a scrolling view :(

I hope you come back to give this some love soon!

Did you find any working solution, I need to animate grid changes too

@Snonky
Copy link
Contributor

Snonky commented Oct 2, 2023

I took a shot at patching this in. Until @letsar finds time for the PR you can use my fork and maybe supply feedback if it achieves your needs.

To use the fork directly from git put this in your pubspec.yaml:

  local_hero:
    git:
      url: https://github.com/Snonky/local_hero.git
      ref: feature/only-remount

To enable the scroll support set onlyAnimateRemount to true in your LocalHeroScope.
This option supresses animations that come from position changes without tree surgery (e.g. scrolls or padding changes).

Before:
local_hero_before

After:
local_hero_after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants