Admin notice not displaying

The add_action function only adds the action to a queue, which will be executed when the corresponding do_action is called. So, when you queue it too late, nothing will happen.

To know for sure what happens in your case, you must carefully examine the order of the hook execution. That requires insight in your complete setup, including plugins and so on.

My guess is that by the time isset($_POST['post_saved']) is true do_action ('admin_notices') is already executed and queueing something for it is useless.

The way to solve this is not to add the action conditionally. Always add the action and put the test inside the function. Like this:

add_action('admin_notices', 'image_error');
function image_error () {
  $flag_worked = isset($_POST['post_saved']);
  if ($flag_worked) {
    echo 'error';
    }