Skip to content

Instantly share code, notes, and snippets.

@f1dz
Created August 7, 2022 08:41
Show Gist options
  • Save f1dz/d80bbb6ac4c7c35314138844f21515b8 to your computer and use it in GitHub Desktop.
Save f1dz/d80bbb6ac4c7c35314138844f21515b8 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class OrderButton extends StatefulWidget {
const OrderButton({Key? key}) : super(key: key);
@override
State<OrderButton> createState() => _OrderButtonState();
}
class _OrderButtonState extends State<OrderButton> {
int qty = 0;
@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () {
setState(() {
if (qty > 0) qty--;
});
},
child: const Icon(Icons.remove),
),
const SizedBox(width: 8),
Text("$qty"),
const SizedBox(width: 8),
InkWell(
onTap: () {
setState(() {
qty++;
});
},
child: const Icon(Icons.add),
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment