This file contains 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'; | |
import 'package:foodrop/core/models/item.dart'; | |
class ItemWidget extends StatelessWidget { | |
final Item item; | |
final Function(Item) onTap; | |
ItemWidget({@required this.item, this.onTap}); | |
@override |
This file contains 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'; | |
import 'package:flutter/rendering.dart'; | |
import 'list_extension.dart'; | |
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; | |
void main() { | |
runApp(MyApp()); | |
debugPaintSizeEnabled = false; | |
} |
This file contains 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
@override | |
Widget build(BuildContext context) { | |
return GestureDetector( | |
onTap: () { | |
onTap(item); | |
}, | |
child: SizedBox( | |
height: 500, | |
child: Card( | |
color: Colors.grey[800], |
This file contains 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 'dart:async'; | |
import 'dart:collection'; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:provider/provider.dart'; | |
void main() { | |
runApp(MyApp()); | |
} |
This file contains 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
class Client { | |
private ServiceA a; | |
private ServiceB b; | |
// Property injection | |
public ServiceC c; | |
// Constructor injection | |
public Client(ServiceA a, ServiceB b) { |
This file contains 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
synchronized (this) { | |
if (mNumberOfTickets >= amount) { | |
mNumberOfTickets = mNumberOfTickets - amount; | |
} else { | |
// Tickets all sold! | |
} | |
} |
This file contains 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
public class Main { | |
public static void main(String[] args) throws Exception { | |
final TicketManager tm = new TicketManager(); | |
Thread t1 = new Thread(new Runnable() { | |
public void run() { |
This file contains 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
class TicketManager { | |
private int mNumberOfTickets = 100; | |
void purchaseTickets(int amount) { | |
someTimeIntensiveTask(); | |
if (mNumberOfTickets >= amount) { |
This file contains 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
class TicketManager { | |
private int mNumberOfTickets = 100; | |
synchronized void purchaseTickets(int amount) { | |
if (mNumberOfTickets >= amount) { | |
makingNetworkConnectionToServer(); |
This file contains 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
public class Main { | |
public static void main(String[] args) throws Exception { | |
final TicketManager tm = new TicketManager(); | |
Thread t1 = new Thread(new Runnable() { | |
public void run() { | |
tm.purchaseTickets(90); | |
} |
NewerOlder