Skip to content

Instantly share code, notes, and snippets.

@esDotDev
Created August 15, 2025 20:22
Show Gist options
  • Select an option

  • Save esDotDev/da6bf4fd2b0f99410e67593afaf76d44 to your computer and use it in GitHub Desktop.

Select an option

Save esDotDev/da6bf4fd2b0f99410e67593afaf76d44 to your computer and use it in GitHub Desktop.
import 'package:existence/src/app_libs.dart';
import 'package:flutter/material.dart';
class ParallaxGridSpike extends StatefulWidget {
const ParallaxGridSpike({super.key});
@override
State<ParallaxGridSpike> createState() => _ParallaxGridSpikeState();
}
class _ParallaxGridSpikeState extends State<ParallaxGridSpike> {
Offset _mouseOffset = Offset.zero;
@override
Widget build(BuildContext context) {
return Scaffold(
body: MouseRegion(
onHover: (details) {
final centerPos = Offset(context.widthPx / 2, context.heightPx / 2);
final offset = Offset(
(details.localPosition.dx - centerPos.dx) / context.widthPx,
(details.localPosition.dy - centerPos.dy) / context.heightPx,
);
print(offset);
setState(() => _mouseOffset = offset);
},
child: Stack(
children: [
Transform.translate(
offset: -_mouseOffset * 50,
child: GridView.builder(
itemCount: 100,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8),
itemBuilder: (_, index) {
return AppBtn(
type: AppBtnType.tertiary,
padding: EdgeInsets.zero,
onPressed: () {},
child: IgnorePointer(
child: Container(
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
decoration: BoxCornersDecoration(),
child: Transform.translate(
offset: -_mouseOffset * 10,
child: Center(
child: Text('ITEM $index', style: TextStyle(fontSize: 12)),
),
),
),
),
);
},
),
),
Transform.translate(
offset: -_mouseOffset * 30,
child: BottomCenter(
child: Padding(
padding: EdgeInsets.all(16),
child: Container(color: Colors.grey, width: 600, height: 80),
),
),
)
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment