Created
December 21, 2020 23:06
-
-
Save ridhoperdana/968a0df70a3affa070e3b1432e5f2d1a to your computer and use it in GitHub Desktop.
example of callback function in dart
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 Car { | |
String get type { | |
return 'Hatchback'; | |
} | |
} | |
String carFactory() { | |
return Car().type; | |
} | |
String produceVehicle(Function factory) { | |
var vehicle = factory(); | |
return 'Vehicle $vehicle is created successfully'; | |
} | |
void main() { | |
print(produceVehicle(carFactory)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment