fork download
  1. import 'dart:io';
  2.  
  3. import 'dart:math';
  4.  
  5. void main() {
  6. dynamic shape = 'Circle';
  7.  
  8. dynamic result = [];
  9.  
  10. result
  11. ..add(shape is! String ? 'Unknown' : shape)
  12. ..add(
  13. shape == 'Circle' ? (pi * 5 * 5).toStringAsFixed(2)
  14. : shape == 'Rectangle' ? (4 * 3).toString()
  15. : 'Unknown');
  16.  
  17. print('Shape: ${result[0]}');
  18. print('Area: ${result[1]}');
  19. }
  20.  
Success #stdin #stdout 1.67s 129956KB
stdin
Standard input is empty
stdout
Shape: Circle
Area: 78.54