Skip to content

Instantly share code, notes, and snippets.

@AlejoCumpa
Created January 28, 2024 15:39
Show Gist options
  • Save AlejoCumpa/0bc540988ad287e02f53662a89c40d76 to your computer and use it in GitHub Desktop.
Save AlejoCumpa/0bc540988ad287e02f53662a89c40d76 to your computer and use it in GitHub Desktop.
class ButtonCircle extends StatelessWidget {
const ButtonCircle({super.key, required this.width});
final double width;
@override
Widget build(BuildContext context) {
return Container(
width: width, //width of the base circle
height: width, //height of the base circle
color: Colors.grey,
child: Stack(
children: [
Positioned(
left: 0,
top: width / 6,
child: GestureDetector(
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('No Ads Pressed'),
duration: Duration(milliseconds: 300),
),
);
},
child: Image.asset(
"assets/images/circle_left.png",
fit: BoxFit.contain,
height: width * 2 / 3,
width: width / 3,
),
),
),
Positioned(
left: width * 2 / 3,
top: width / 6,
child: GestureDetector(
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Random Pressed'),
duration: Duration(milliseconds: 300),
),
);
},
child: Image.asset(
"assets/images/circle_right.png",
fit: BoxFit.contain,
height: width * 2 / 3,
width: width / 3,
),
),
),
Positioned(
left: width / 6,
top: 0,
child: GestureDetector(
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Leaderboard Pressed'),
duration: Duration(milliseconds: 300),
),
);
},
child: Image.asset(
"assets/images/circle_up.png",
fit: BoxFit.contain,
height: width / 3,
width: width * 2 / 3,
),
),
),
Positioned(
left: width / 6,
top: width * 2 / 3,
child: GestureDetector(
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Info Pressed'),
duration: Duration(milliseconds: 300),
),
);
},
child: Image.asset(
"assets/images/circle_down.png",
fit: BoxFit.contain,
height: width / 3,
width: width * 2 / 3,
),
),
),
Positioned(
left: width * 0.3,
top: width * 0.3,
child: GestureDetector(
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Play Pressed'),
duration: Duration(milliseconds: 300),
),
);
},
child: Image.asset(
"assets/images/circle.png",
fit: BoxFit.contain,
height: width * 0.4,
width: width * 0.4,
),
),
),
],
),
);
}
}
class Demo extends StatefulWidget {
const Demo({super.key});
@override
State<Demo> createState() => _DemoState();
}
class _DemoState extends State<Demo> {
late Size? screenSize;
@override
void didChangeDependencies() {
super.didChangeDependencies();
screenSize = MediaQuery.of(context).size;
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Demo"),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(12.0),
child: ButtonCircle(width: screenSize!.width * 0.8),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment