Back to Society
Computer
how to write a function in flutter
Commenter Image

kabita prasad

Here’s a quick breakdown of how to write a function in Dart/Flutter
Basic Syntax of a Function
ReturnType functionName(parameters) {
// Function body
return value;
}
Simple Function with No Parameters
void sayHello() {
print('Hello from Flutter!');
}
Function with Parameters
void greetUser(String name) {
print('Hello, $name!');
}