Home > Back-end >  SET and GET in dart, Flutter
SET and GET in dart, Flutter

Time:06-30

Could you please explain what do set and get do in the code bellow?

class AppScrollBehavior extends MaterialScrollBehavior {

  @override

  Set<PointerDeviceKind> get dragDevices => {

        PointerDeviceKind.touch,
        PointerDeviceKind.mouse,

      };
}

CodePudding user response:

Set is one of the Data Types in Dart. A Set is the collection of objects in which each object can occur only once.

According to documentation:-

A collection of objects in which each object can occur only once. That is, for each object of the element type, the object is either considered to be in the set, or to not be in the set. Set implementations may consider some elements indistinguishable. These elements are treated as being the same for any operation on the set. The default Set implementation, LinkedHashSet, considers objects indistinguishable if they are equal with regard to Object.== and Object.hashCode.

More about Set here

and get Getters are special methods that provide read and to an object’s properties.

CodePudding user response:

set is used to assign a value and get us used to get the assign value like you can return a value to function.

  • Related