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
/// Describes a television screen resolution | |
class ResolutionSize { | |
/// The natural width of this resolution | |
final int width; | |
/// The natural height of this resolution | |
final int height; | |
/// A shorter technical name | |
final String name; |
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
void main() { | |
BvItem test1Item = BvItem(netSize: 1); | |
BvItem test2Item = BvItem(netSize: 6); | |
BvItem test3Item = BvItem(netSize: 7); | |
BvItem test4Item = BvItem(netSize: 8); | |
BvItem test5Item = BvItem(netSize: 14); | |
BvItem test6Item = BvItem(netSize: 15); | |
BvItem test7Item = BvItem(); // yes, null. | |
num? netSizeA = isGrouped(test1Item) ?? (test1Item.netSize ?? -1); |
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
Future<void> doAThing() async { | |
await Future.delayed(Duration(milliseconds: 500)); | |
try { | |
print('Trying a dangerous thing...'); | |
await doADangerousThing(); | |
} catch (e) { | |
print('There was a minor error: $e'); | |
rethrow; | |
} |
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:mirrors'; | |
class User { | |
final String email; | |
final String name; | |
const User({required this.email, required this.name}); | |
} | |
extension DeclarationMirrorExtension on DeclarationMirror { | |
/// Name of this object or field |
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:convert'; | |
class Product { | |
String name; | |
Product({ required this.name }); | |
Map<String, dynamic> toJson() { | |
const json = <String, dynamic>{}; | |
json['name'] = name; |
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
void main() { | |
List<String> uninitializedList; | |
try { | |
if (uninitializedList?.length == 1) { | |
print('Length is equal to 1, not equal to null.'); | |
} else { | |
print('Length is not equal to 1, it is equal to null'); | |
} | |
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:math'; | |
/// Describes a distance unit for conversion | |
enum Unit { | |
miles, | |
kilometers, | |
nauticalMiles, | |
} | |
/// Describes a decimal coordinate |
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 PaymentLine { | |
double price; | |
String name; | |
int qty; | |
PaymentLine({ this.price, this.name, this.qty }); | |
} | |
void main() { | |
List<PaymentLine> payments = <PaymentLine>[]; |
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 'dart:async'; | |
import 'dart:math'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class RandomNumberStream { | |
final StreamController<int> _nextRandomNumberController = StreamController<int>(); |
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'; | |
class State with ChangeNotifier { | |
late num _count; | |
num get count => _count; | |
void setCount(newCount) { | |
_count = newCount; | |
notifyListeners(); | |
} |