Create Rows

Create a Single Row

You can create a new row in a Data Store table of the given instance using the newRow() method. You must set the values of the rows in the table, by specifying the column name and the corresponding row value as a key-value pair.

The <ROW_INSTANCE> used in the code syntax below is the instance defined in the Row Instance page.

<ROW_INSTANCE>.create( void Function(ZCatalystRow) onSuccess, void Function(ZCatalystException) onFailed )
Note: If a column was created with the is_unique or is_mandatory property enabled, you must ensure that the value is unique or is mandatorily passed, respectively. You must also ensure that the data you pass for a column is of the column's configured data type.

A sample code snippet with creating a row instance is shown below:

var row = ZCatalystApp.getInstance() .getDataStoreInstance() .getTableInstance(identifier: 'Products') .newRow(); //Defining the row instance for the table and passing the key-value data for the row row.setColumnValue('product_name', 'power_bank'); row.setColumnValue('product_price', 2000); row.setColumnValue('product_quantity', 2); row.create( onSuccess: (APIResponse response, ZCatalystRow row) { print('New row created successfully : ${}'); }, //Actions to be executed upon successfully creating the row onFailed: (ZCatalystException exception) { print('Failed to create the row: $exception'); }, );

Create Multiple Rows

Catalyst Flutter SDK enables you to create multiple rows at a time in a table of the given instance. This is done by passing a list containing the rows that need to be inserted in the table. The list is passed as an argument to the createRows() method, as shown in the code syntax below.

The <TABLE_INSTANCE> used in the code below is the instance defined in the Table Instance page.

<TABLE_INSTANCE>.createRows( List<ZCatalystRow> rows, void Function(List<ZCatalystRow>) onSuccess, void Function(ZCatalystException) onFailed )


  • rows: The array of rows to be created

A sample code snippet with creating row instances is shown below:

List<ZCatalystRow> newRows = []; //Create an array //Define row instances for rows to be created ZCatalystRow row1 = dataStore.getTableInstance(identifier: 'Products').newRow(); row1.setColumnValue('product_name', 'a'); row1.setColumnValue('product_price', 25); row1.setColumnValue('product_quantity', 50); ZCatalystRow row2 = dataStore.getTableInstance(identifier: 'Products').newRow(); row2.setColumnValue('product_name', 'b'); row2.setColumnValue('product_price', 30); row2.setColumnValue('product_quantity', 40); ZCatalystRow row3 = dataStore.getTableInstance(identifier: 'Products').newRow(); row3.setColumnValue('product_name', 'c'); row3.setColumnValue('product_price', 25); row3.setColumnValue('product_quantity', 70); //Add row instances to the array newRows.add(row1); newRows.add(row2); newRows.add(row3); dataStore.getTableInstance(identifier: 'Products').createRows( rows: newRows, //Pass the array as an argument to the method onSuccess: (APIResponse response, List<ZCatalystRow> rows) { print( 'The IDs of the rows that were successfully created are listed below:'); for (var row in rows) { print(; //Actions to be executed upon a successful creation of the rows } }, onFailed: (ZCatalystException exception) { print('Exception thrown: $exception'); //Actions to be executed upon a failed state }, );

Last Updated 2023-09-03 11:54:50 +0530 +0530