createAggregateFunction<V> method Null safety

void createAggregateFunction<V>(
  1. {required String functionName,
  2. required AggregateFunction<V> function,
  3. AllowedArgumentCount argumentCount = const AllowedArgumentCount.any(),
  4. bool deterministic = false,
  5. bool directOnly = true}

Creates an application-defined aggregate function that can be used from sql queries sent against this database.

The argumentCount parameter can be used to declare how many arguments a function supports. If you need a function that can use multiple argument counts, you can call createFunction multiple times. The deterministic flag (defaults to false) can be set to indicate that the function always gives the same output when the input parameters are the same. This is a requirement for functions that are used in generated columns or partial indexes. It also allows the query planner for optimize by factoring invocations out of inner loops. The directOnly flag (defaults to true) is a security measure. When enabled, the function may only be invoked form top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in schema structures (such as CHECK, DEFAULT, etc.). When directOnly is set to false, the function might be invoked when opening a malicious database file. sqlite3 recommends this flag for all application-defined functions, especially if they have side-effects or if they could potentially leak sensitive information.

For more details on how to write aggregate functions (including an example), see the documentation of AggregateFunction.


void createAggregateFunction<V>({
  required String functionName,
  required AggregateFunction<V> function,
  AllowedArgumentCount argumentCount = const AllowedArgumentCount.any(),
  bool deterministic = false,
  bool directOnly = true,