Code Monkey home page Code Monkey logo

Comments (12)

lukepighetti avatar lukepighetti commented on June 19, 2024 2

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,
              ),
          ],
        );
      },
    );
  }
}

from local_hero.

MarazMia avatar MarazMia commented on June 19, 2024 1

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

from local_hero.

Snonky avatar Snonky commented on June 19, 2024 1

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

from local_hero.

letsar avatar letsar commented on June 19, 2024

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.

from local_hero.

letsar avatar letsar commented on June 19, 2024

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 😕.

from local_hero.

jimmy-robert avatar jimmy-robert commented on June 19, 2024

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.

from local_hero.

letsar avatar letsar commented on June 19, 2024

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 😉

from local_hero.

rbozan avatar rbozan commented on June 19, 2024

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 :)

from local_hero.

TJMusiitwa avatar TJMusiitwa commented on June 19, 2024

@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

from local_hero.

lukepighetti avatar lukepighetti commented on June 19, 2024

This might be helpful to you https://gist.github.com/lukepighetti/df460db180b9f6cb3410e3cc91ed74e6

from local_hero.

TDuffinNTU avatar TDuffinNTU commented on June 19, 2024

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!

from local_hero.

abdelaziz-mahdy avatar abdelaziz-mahdy commented on June 19, 2024

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

from local_hero.

Related Issues (11)

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.