To make widget arguments optional, you either have to make them nullable or provide a default value. Also, currently, you do not specify Function arguments, but widget arguments. Function arguments in this case are optional if they are named - inside curly braces.
Here is an example how to provide more information to your function.
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
String bar({int? index, List<String> contact = const []}) {
return 'foo';
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: Foo(
fixContact: bar,
),
),
),
);
}
}
class Foo extends StatefulWidget {
const Foo({
required this.fixContact,
super.key,
});
final String Function(
{int index,
List<String> contact
}) fixContact;
@override
State<Foo> createState() => _FooState();
}
class _FooState extends State<Foo> {
@override
Widget build(BuildContext context) {
return Text(widget.fixContact(index: 5));
}
}