Controller constructor

const Controller([
  1. String? value
])

Controller annotation for Jet View controllers

This annotation marks a class as a Jet View controller. Unlike @RestController, methods return view names by default.

Example Usage:

@Controller('/web')
class WebController {
  final UserService userService;
  
  WebController(this.userService);
  
  @GetMapping('/users')
  String listUsers(Model model) {
    model.addAttribute('users', userService.findAll());
    return 'users/list';
  }
  
  @GetMapping('/users/{id}')
  String viewUser(@PathVariable('id') String id, Model model) {
    model.addAttribute('user', userService.findById(id));
    return 'users/view';
  }
  
  @ResponseBody
  @GetMapping('/api/users')
  Future<List<User>> getUsersApi() async {
    return userService.findAll();
  }
}

Implementation

const Controller([this.value]);