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'; | |
void main() { | |
NumberQ num1 = NumberQ( | |
signal: NumberQSignal.positive, | |
integer: 1, | |
fractionNum: 2, | |
fractionDen: 3, | |
); | |
NumberQ num2 = NumberQ( |
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'; | |
Stream<int> getStream(int n) async* { | |
if (n > 0) { | |
await Future.delayed(Duration(seconds: 1)); | |
yield n; | |
yield* getStream(n - 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
void main() async { | |
print('aaa'); | |
Stream<int> stream = countStream(10); | |
print('bbb'); | |
int sum = await sumStream(stream); | |
print('ccc'); | |
print(sum); | |
} | |
Stream<int> countStream(int max) async* { |
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() { | |
for (int i = 0; i < 5; i++) { | |
print('hello ${i + 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:async'; | |
import 'dart:typed_data'; | |
import 'package:flutter/material.dart'; | |
import 'package:pdf/widgets.dart' as pw; | |
import 'package:printing/printing.dart'; | |
class UserProfilePrintPage extends StatelessWidget { | |
const UserProfilePrintPage({Key? key}) : super(key: key); |
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 UsingSingleton { | |
// using a factory is important | |
// because it promises to return _an_ object of this type | |
// but it doesn't promise to make a new one. | |
factory UsingSingleton() { | |
print('... factory UsingSingleton()'); | |
return _instance; | |
} | |
static final UsingSingleton _instance = UsingSingleton._internal(); | |
// This named constructor is the "real" constructor |
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() { | |
var myClass = MyClass(); | |
myClass.doSomething1(1); | |
myClass.doSomething2(printAnyThing1); | |
myClass.doSomething3((value) { | |
print('print $value'); | |
}); | |
myClass.doSomething4((value) { | |
print('print $value'); | |
return 2; |
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() { | |
String valorDoSaque = '9'; | |
sacar(valorDoSaque); | |
} | |
void sacar(String valorDoSaque) { | |
if (int.parse(valorDoSaque) > 0 && int.parse(valorDoSaque) < 1000) { | |
var notas = valorEmNotas(valorDoSaque); | |
var texto = valorEmTexto(valorDoSaque); | |
if (notas == 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
abstract class Item { | |
String name(); | |
Packing packing(); | |
double price(); | |
} | |
abstract class Packing { | |
String pack(); | |
} |
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
enum ShapeType { circle, square } | |
abstract class Shape { | |
factory Shape(ShapeType type) { | |
switch (type) { | |
case ShapeType.circle: | |
return Circle(); | |
case ShapeType.square: | |
return Square(); | |
} |