Comments (7)
Hi @Roxin92 thank you for opening an issue!
I am a bit confused about a couple of parts in your code, for instance you are declaring heroProperties
inside the itemBuilder
. This would trigger the for loop for every single child you pass into the GridView
. I'd recommend you to check your heroProperties
data. You also have a separate declaration of swipeImageGallery
and you are accessing the heroProperties from inside this, which declaration is this one getting? You need to pass the complete list of hero props inside this.
I can recommend you to try something like below as I have tried this just now and it seems to work, but thank you for pointing this out, I will add it to the example and the README as it is a good addition.
class _ImageGalleryExamplesPageState extends State<ImageGalleryExamplesPage> {
final List<ImageGalleryHeroProperties> heroProperties = [];
@override
void initState() {
for (var i = 0; i < remoteImages.length; i++) {
heroProperties.add(
ImageGalleryHeroProperties(tag: '${i}image'),
);
}
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: GridView.builder(
itemCount: remoteImages.length,
itemBuilder: (BuildContext context, int index) {
return InkResponse(
onTap: () => SwipeImageGallery(
children: remoteImages,
heroProperties: heroProperties,
context: context,
initialIndex: index,
).show(),
child: GridTile(
child: Hero(
tag: '${index}image',
child: remoteImages[index],
),
),
);
},
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 0.8,
),
),
);
}
}
Let me know if this helps
from swipe_image_gallery.
Hi @dbilgin, thanks for the fast reply first of all great library i love it. Sorry for the messy code i posted it was just snippets from the actual code but i did edit it for clarity to answer your question why i did put the loop in the itemBuilder
? Is because i was stuck and just trying out where it might work but realized now it was a bad idea and why im having a separate swipeImageGallery
declaration? Is because the code was getting long and messy with the overlays added, will having it separately affect the hero props? And in my case i don't have children im using itemBuilder
will the hero animations still work with it?, My remote images are retrieved with a FutureBuilder
so i must wait for it to complete first so i won't be able to run the loop in the initState
any idea on where i can run that loop according to my code?
from swipe_image_gallery.
Thank you @Roxin92, I appreciate that.
I didn't mean that you shouldn't use a separate declaration of swipeImageGallery
, it's just that you were accessing the list of hero properties inside it directly, that could cause a problem.
I see that on this line widget.wallpaperList.add(wallpaper);
you already have you images resolved from the future, so you don't need to declare the ImageGalleryHeroProperties
inside the itemBuilder
. For your specific case if you have to do it this way, I would declare the heroProperties
before the return of the GridView
and pass the heroProperties
as a parameter to the swipeImageGallery
. Of course at the same time you would have to declare the Hero widget inside GridTile
.
If you have a repository you can share with me I can possibly help you out more, but currently this seems like more of a code structure issue rather than something with the image gallery.
from swipe_image_gallery.
@dbilgin I will really appreciate that here is my repository https://github.com/Roxin92/SwipeImageGallery.git
Yeah i also think is do with my code the way how to structure the code it has nothing to do with image gallery im just stuck on how i will be able to loop through and apply the images ids as unique tags to the hero properties.
from swipe_image_gallery.
@Roxin92 your repository is empty
from swipe_image_gallery.
@dbilgin Sorry just created it now and forget to import the code but actually it's working now just did what you said declared the the heroProperties
before the return of the GridView
and did pass the heroProperties as a parameter to the swipeImageGallery
Of course at the same time have declared the Hero widget inside GridTile
and everything is super now thanks for your time really appreciate it.
from swipe_image_gallery.
@Roxin92 that's awesome, thank you for letting me know, I'm glad it works now :) Enjoy!
Will be closing this thread now since it's resolved.
from swipe_image_gallery.
Related Issues (12)
- Zoomed image position HOT 6
- Add opportunity to change opacity of overlay HOT 4
- Swipe not working on Linux build HOT 3
- index of gallery HOT 4
- rror G9EFD8EEC: Member not found: 'trackpad'. HOT 2
- Transparent backgroundColor displayed as solid color HOT 1
- show() method should return a Future HOT 1
- Cannot dismiss using back button HOT 4
- Please add click disappear function. HOT 4
- Make opacity of overlay and opacity of background controllable HOT 1
- Swipe direction HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swipe_image_gallery.