You’ll need to combine the one for the flexible content row with the one for the repeater row just above it.
$field_key = "flexible_field";
$value = get_field($field_key);
$value[] = array(
"sub_field_1" => "Foo1",
"sub_field_2" => "Bar1",
"repeater_field" => array(
array(
'repeater_sub_1' => 'value',
'repeater_sub_2' => 'value'
)
),
"acf_fc_layout" => "layout_1_name"),
;
update_field( $field_key, $value, $post_id );