Theme and prefix routing

I have created new theme as Plugin following Cakephp 3.x documentation.

in my AppController i have condition to load different themes.

   // Layouts
   $this->viewBuilder()->setTheme('Legacy'); //default theme
   if (!is_null($this->request->getParam('prefix'))) {
       $prefix = explode('/', $this->request->getParam('prefix'))[0];
       switch ($prefix) {
           case 'c':
               $this->viewBuilder()->setTheme('Campaign');
               break;
           case 'admin':
               $this->viewBuilder()->setTheme('Admin');
               break;
        }
    }

my default route for admin prefix is:

Router::prefix('admin', function ($routes) {
    // All routes here will be prefixed with `/admin`
    // And have the prefix => admin route element added.
    $routes->connect('/', ['controller' => 'Users', 'action' => 'dashboard']);
    $routes->fallbacks('InflectedRoute');
});

but when i got in browser to http://localhost:8180/admin/

i see only error:
Error: The view for UsersController::dashboard() was not found.
Confirm you have created the file: “Admin/Users/dashboard.ctp” in one of the following paths:
/var/www/myapp/src/Template/Admin/Users/dashboard.ctp

my dashboard.ctp is in the Plugin folder plugins/Admin/src/Template/Users/dashboard.ctp

am i doing something wrong here ?
should the theme views be placed in plugin folder as suggested in documentation or in
/var/www/myapp/src/Template/THEMENAME/ …

in that connect function write name instated of /

Can you try like this?

Router::prefix('admin', function ($routes) {
    // All routes here will be prefixed with `/admin`
    // And have the prefix => admin route element added.
    $routes->connect('/', ['plugin'=>'admin','controller' => 'Users', 'action' => 'dashboard']);
    $routes->fallbacks('InflectedRoute');
});

I don’t want to create complete admin plugin (controllers,plugins etc). I want to have only admin theme, meaning when i set the theme in my AppController i want that the template files are loaded from the theme/plugin folder templates as described in documentation.

Anyway i tried your suggestion, now getting Missing Controller exception.

Error: Create the class UsersController below in file: /var/www/myapp/plugins/Admin/src/Controller/Admin/UsersController.php

the path is very strange… why would i need to create Admin folder inside Admin’s plugin Controller ?
seems to me that there is a problem with creating themes in 3x (as suggested in documentation - theme is now a plugin)

It works for me without prefixed routes (i set a theme and use the view templates from the Plugin folder.
However if there is a prefixed route, it does not work as expected.