Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/cart_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'models/payment.dart';
import 'models/product.dart';
import 'models/shop.dart';
import 'utils/formatter.dart';
import 'widgets/cart_item_counter.dart';
import 'widgets/payment_info.dart';
import 'widgets/shop_info.dart';

Expand Down
9 changes: 9 additions & 0 deletions lib/widgets/cart_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ class CartItem extends StatelessWidget {
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CartItemCounter(),
SizedBox(
width: 20,
),
],
),
SizedBox(
height: 20,
),
Expand Down
32 changes: 32 additions & 0 deletions lib/widgets/cart_item_counter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:flutter/material.dart';

class CartItemCounter extends StatelessWidget {
const CartItemCounter({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.withOpacity(0.4),
),
borderRadius: BorderRadius.circular(6),
),
child: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
IconButton(
icon: Icon(Icons.remove),
disabledColor: Colors.grey,
onPressed: () {},
),
Text('1'),
IconButton(
icon: Icon(Icons.add),
onPressed: () {},
),
],
),
);
}
}
23 changes: 23 additions & 0 deletions lib/widgets/counter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';

class Counter extends InheritedWidget {
const Counter({
Key? key,
required this.value,
required Widget child,
}) : super(key: key, child: child);

final int value;

static Counter of(BuildContext context) {
final Counter? result =
context.dependOnInheritedWidgetOfExactType<Counter>();
assert(result != null, 'No Counter found in context');
return result!;
}

@override
bool updateShouldNotify(Counter old) {
return old.value != value;
}
}