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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreviewBuilder size limited when a widget is in a GridView #475

Open
MaherSafadii opened this issue Dec 18, 2024 · 0 comments
Open

PreviewBuilder size limited when a widget is in a GridView #475

MaherSafadii opened this issue Dec 18, 2024 · 0 comments

Comments

@MaherSafadii
Copy link

There is an issue where if I want to have a larger in as preview in a GridView it won't work, while it expands to the larger preview normally when there's no GridView, there seems to be a constraint in the GridView that's effecting the previewBuilders size, it also happens in SliverGridViews I ran into it while build a photo gallery app, I wanted the original large photo to show when I hold a photo, so it would be great if it gets fixed, or if there is a workaround or something else I may be unaware of.

Recording.at.2024-12-19.00.41.27.mp4
Recording.at.2024-12-19.00.43.16.mp4

code for a normal use case example:

`
class ContextMenuExample extends StatelessWidget {
const ContextMenuExample({super.key});

@OverRide
Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: Center(
child: ContextMenuWidget(
previewBuilder: (context, child) {
return Container(
height: 500,
width: 500,
color: Colors.amber.shade600,
padding: const EdgeInsets.all(54),
child: const Text('Custom menu preview'),
);
},
child: Container(
height: 100,
width: 100,
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: CupertinoColors.systemBlue,
borderRadius: BorderRadius.circular(15),
),
child: const Center(child: Text('Menu')),
),
menuProvider: (_) {
return Menu(
children: [
MenuAction(
image: MenuImage.icon(Icons.access_time),
title: 'Menu Item 1',
callback: () {},
),
],
);
},
),
),
);
}
}
`

code for the GridView example:

`class ContextMenuGrid extends StatelessWidget {
const ContextMenuGrid({super.key});

@OverRide
Widget build(BuildContext context) {
return GridView.builder(

  gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
    crossAxisCount: 3,
    crossAxisSpacing: 10,
    mainAxisSpacing: 10,
  ),
  itemCount: 30,
  itemBuilder: (context, index) {
    return ContextMenuWidget(
      previewBuilder: (context, child) {
        return Container(
          height: 500,
          width: 500,
          color: Colors.amber.shade600,
          padding: const EdgeInsets.all(54),
          child: const Text('Custom menu preview'),
        );
      },
      child: Container(
        padding: const EdgeInsets.all(20),
        decoration: BoxDecoration(
          color: CupertinoColors.systemBlue,
          borderRadius: BorderRadius.circular(15),
        ),
        child: const Center(child: Text('Menu')),
      ),
      menuProvider: (_) {
        return Menu(
          children: [
            MenuAction(
              image: MenuImage.icon(Icons.access_time),
              title: 'Menu Item 1',
              callback: () {},
            ),
          ],
        );
      },
    );
  },
);

}
}
`

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

1 participant