double average(List <double> darray) {
double sum = 0;
darray.forEach((value)
{sum += value;}
);
return sum/darray.length;
}
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:http/http.dart' as http; | |
import 'dart:io'; | |
void main(List<String> arguments) async { | |
try { | |
var resp = await fetchJson(url:'https://jsonplaceholder.typicode.com/posts'); | |
fetchJson(url:'https://i.pinimg.com/564x/e6/57/1a/e6571a6c62fb2615c741a8fcf32aef49.jpg'); | |
print('Print json \n${resp.body}'); |
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() { | |
final p = SuperPrinter<int>(1); | |
p.doPrint(); | |
final pString = SuperPrinter<String>('Awesome dart'); | |
pString.doPrint(); | |
var st = Student(2020); | |
st.name = 'Stas'; |
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 sh = CustomShape(); | |
sh.getBorder(sh.borders); | |
} | |
class CustomShape extends Shape with BorderHelper { | |
CustomShape(): super([1.0, 2.0]); | |
} | |
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
main() { | |
var userMain = User(); | |
userMain.name = 'Boris'; | |
print('Your name: ${userMain.name}'); | |
var st = Student(2020); | |
st.name = 'Stas'; | |
st.surname = 'Konovalov'; | |
print('New student: $st'); | |
} |
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'; | |
String solve({double ax, double bx, double cx}) { | |
double discriminant({double a, double b, double c}) { | |
return (b*b - 4*a*c); | |
} | |
double calculateX({double a, double b, double c, int xType = 1}) { | |
double singDiscr; | |
final sqrtD = sqrt(discriminant(a: a, b:b, c:c)); | |
if (xType == 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
// 1 | |
void reverse([String text = '']) { | |
print('New line: ${text.split(' ').reversed.join(' ')}'); | |
} | |
void main() { | |
var a = 'hello world'; | |
reverse(); | |
} |
void reverse(String text) {
print('New line: ${text.split(' ').reversed.join(' ')}');
}
void main() {
var a = 'hello world';
reverse(a);
}
import 'dart:io';
void addUp() {
var input = '';
double sum = 0;
do {
input = stdin.readLineSync();
double value = double.tryParse(input);
void evenNumbers() {
print('Print all even number');
for (int i = 0; i <= 100; i = i+2) {
print(i);
}
}
NewerOlder