Created with <3 with dartpad.dev.
Created
August 19, 2022 18:50
-
-
Save abdorll/9f68d7605ec76e8615751bb9dbc4c4d5 to your computer and use it in GitHub Desktop.
hollow-eucalyptus-9972
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(){ | |
int toAdd =0; | |
int add =bikes.fold(toAdd, (a,b)=> a + b.power!); | |
print(bikes.singleWhere((a)=> a.power!>7, orElse).name! ); | |
// print (add); | |
// print(bikes.where((e)=> | |
// e.name!.contains('b')). | |
// map((e)=> e.name!).toList()); | |
//bikes.every((a)=> a.power!>1)?print('>1'):print('<1'); | |
// final names= carsName.reduce((a,b)=>'$a$b'); | |
// print(names); | |
// final power= | |
// carsPower..sort((a,b)=> a.compareTo(b)); | |
// power.forEach((car)=> print(car)); | |
// carsName.contains("ax")?print('yes'):print('no'); | |
//print(carsName[0][0]); | |
//carsName.forEach((car)=> print(car)); | |
} | |
final carsName = | |
bikes.map((bike){ | |
final name = bike.name; | |
return '$name'; | |
}).toList(); | |
final carsPower = | |
bikes.map((bike){ | |
final power = bike.power; | |
return '$power'; | |
}).toList(); | |
List <Bikes> bikes = [ | |
Bikes(name: "asx", power: 9), | |
Bikes(name: "wb", power: 2), | |
Bikes(name: "ko", power: 3), | |
Bikes(name: "sem", power: 5), | |
]; | |
class Bikes{ | |
String? name; | |
int? power; | |
Bikes({required this.name, | |
required this.power} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment