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'; | |
double roundDouble(double value, double places) { | |
num mod = pow(10.0, places); | |
return ((value * mod).round().toDouble() / mod); | |
} | |
extension BetterDoubles on num { | |
num roundAsDoubleBetter(double places) { | |
final num mod = pow(10.0, places); |
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() { | |
ten:while(true) { | |
print('Hello world!'); | |
continue ten; | |
break; | |
} | |
} |
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:io'; | |
import 'dart:isolate'; | |
void main(List<String> arguments) async { | |
ReceivePort receivePort = ReceivePort(); | |
Isolate fooIsolate = await Isolate.spawn(foo, receivePort.sendPort); | |
Isolate barIsolate = await Isolate.spawn(bar, receivePort.sendPort); | |
Isolate fooBarIsolate = await Isolate.spawn(fooBar, receivePort.sendPort); |
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 Cannabis { | |
final String uom; | |
final num p; | |
Cannabis(this.uom, this.p); | |
} | |
void main() { | |
List<Cannabis> product = [ | |
Cannabis('%', 5), |
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
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 '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
/// Oct 23, 2020 | |
/// Updated March 17, 2021 | |
/// (c) 2020 James Robert Perih c/o Four And A Half Giraffes, Ltd. | |
void main() { | |
const int theStart = 1; | |
const int theEnd = 100; | |
DartFlutterOutputFactory().printIteration( | |
from: theStart, |
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; |