This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class CartBloc with ChangeNotifier { | |
Map<int, int> _cart = {}; | |
Map<int, int> get cart => _cart; | |
void addToCart(index) { | |
if (_cart.containsKey(index)) { | |
_cart[index] += 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/junjizhi/flutter-shopping-cart | |
import 'cart_bloc.dart'; | |
import 'package:provider/provider.dart'; | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return ChangeNotifierProvider<CartBloc>( | |
builder: (context) => CartBloc(), | |
child: MaterialApp( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns all db files sorted by modified time. Usually the last one is your sqlite db file. | |
gfind /Users/<username>/Library/Developer/CoreSimulator/Devices/ -name "*.db" -printf "%T+\t%p\n" | sort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euxo pipefail | |
# Usage: | |
# cd /path/to/images/directory | |
# bash resize.bash | |
shopt -s extglob | |
for filename in [^resize]*.?(jpg|jpeg|png); do | |
newFile="resized-$filename" |
OlderNewer