Search code examples
fluttersyntaxarrow-functionsflutter-getx

What does " int? get priority => 1;" do?


I was reading a flutter code as below:

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:test_get_app/user_controller.dart';

class AuthMiddleware extends GetMiddleware {
  final authService = UserController.findOrInitialize; // Here is error, this line can't find UserController
  @override
  int? get priority => 1;
  bool isAuthenticated = false;

  @override
  RouteSettings? redirect(String? route) {
    isAuthenticated = true;
    if (isAuthenticated == false) {
      return const RouteSettings(name: '/login');
    }
    return null;
  }
}

When I reached to the following line, I couldn't understand it's syntax and how does it work?

  int? get priority => 1;

Solution

    • int? Means it is an int but the int can be null

    • => 1 Means () {return 1;}