Controller class

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();
  }
}
Annotations
  • @Target.new({TargetKind.classType})

Constructors

Controller([String? value])
Controller annotation for Jet View controllers
const

Properties

annotationType Type
Returns the annotation _type of this annotation.
no setter
effectivePath String?
Gets the effective base path
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value String?
Base path for all endpoints in this controller
final

Methods

equalizedProperties() List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
equals(Object other) bool
Checks whether the given object is logically equivalent to this annotation.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Returns a string representation of this annotation.

Operators

operator ==(Object other) bool
The equality operator.
inherited