// right, bottom两个成员变量提供getter/setter方法 numget right => left + width; set right(num value) => left = value - width; numget bottom => top + height; set bottom(num value) => top = value - height; }
2、类的使用
1 2 3 4 5 6 7 8
main() { var user1 = new Person("zhangsan", 20, "male"); user.age = 30; user.gender = "female"; user.sayHello(); var user2 = new Person.defaultUser() }
classTest{ // 除非你重写noSuchMethod,否则使用不存在的成员会导致NoSuchMethodError // Unless you override noSuchMethod, using a // non-existent member results in a NoSuchMethodError. @override void noSuchMethod(Invocation invocation) { print('You tried to use a non-existent member: ' + '${invocation.memberName}'); } }
/// loadBuffer方法用于加载图片数据并返回ImageStreamCompleter对象。 @override ImageStreamCompleter loadBuffer( image_provider.ExtendedNetworkImageProvider key, DecoderBufferCallback decode) { // Ownership of this controller is handed off to [_loadAsync]; it is that // method's responsibility to close the controller's stream when the image // has been loaded or an error is thrown. final StreamController<ImageChunkEvent> chunkEvents = StreamController<ImageChunkEvent>();