sum method

num sum()

Implementation

num sum() => fold(
    0,
    (num previousValue, dynamic element) =>
        previousValue + (element is num ? element : 0));