Adding widget to dashboard with wp_dashboard_setup not working

Use this code to require the file from your theme’s functions.php file:

require get_template_directory() . 'includes/dashboard.php';

For the sake of completeness (and sanity) my dashboard.php file lives here:

my-theme/includes/dashboard.php

I took a closer look at the original issue, and I think what’s happening is that the require statement is silently failing because the wp-admin/includes/dashboard.php file is actually what’s being included.

To test this, I added the following code to my theme’s functions.php file:

// require 'includes/dashboard.php';
$file_contents = file_get_contents( 'includes/dashboard.php' );
error_log( var_export( $file_contents, true ) );

And the result from PHP’s error log shows that we are indeed including the wrong file.

[27-Dec-2019 20:26:27 UTC] '<?php
/**
 * WordPress Dashboard Widget Administration Screen API
 *
 * @package WordPress
 * @subpackage Administration
 */

/**
 * Registers dashboard widgets.
 *
 * Handles POST data, sets up filters.
 *
 * @since 2.5.0
 *
 * @global array $wp_registered_widgets
 * @global array $wp_registered_widget_controls
 * @global array $wp_dashboard_control_callbacks
 */
function wp_dashboard_setup() {
    global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
    $wp_dashboard_control_callbacks = array();

...