Functions in general - not only in dart - consist of 3 things:
It is like in math for example if you have (y = x + 1). This is a function that takes 'x' as an input and then do a process on that 'x' which is adding '1' to it and thing return the output to 'y'. In this simple example the input type is a number, and the output type is also a number. However, in programming this might not always be the case. For example, you can have a function that takes a word as an input then counts how many character in that word and return the total number of character in that word. But maybe you don't need to know that number. Maybe you just need to store it in a database and come back to it later. In that case, you function would not have to return the number or return anything. It should just save it to the database. What about if you already have that word in the database and you don't have its length there. Your function in that case does not have to take the word as an input it should go to the database by itself, take the word, count the characters, and save the result in the database. You see, fundamentally we still have an input, process, and an output, but the input & output are not being passed in or out to or from the function directly, the functions is taking care of getting its input and returning is output. So it really depends on what you want your function to do.
About the code you posted. Look at the play function it takes songNumber as an input and its type is int, then it is doing some processing like creating a Player object and using the songNumber as part of the actual song file name. Then its output is the song being played from your speaker. The sound you hear is the actual output. You don't need any other output beside the sound. That is why in the code its returning void. In the other hand the output of the second function buildKey is a widget of type Expanded that can be used inside to code. buildKey function also takes a color & a songNumber as an input. Inside buildKey Expanded widget is being created. Inside that widget FlatButton is being created also. The first input (color) is being used to specify the FlatButton Color while the second input (songNumber) is passed the FlatButton onPressed function. onPressed function when are triggered by pressing the button it will call player function giving it the songNumber previously passed.