Typescript Check If Optional Function Parameter Flutter