css 颤动_颤动不同类型的功能

css 颤动

A quick low down on the different types Dart functions you might come across.

快速了解您可能遇到的不同类型的Dart功能。

功能类型: (Types of functions:)

  1. void functions e.g

    无效函数,例如
void greeting() { 
print(‘hello’);
}

2. functions with a return type e.g

2.具有返回类型的函数,例如

String greeting() { 
return ‘Hello’;
}

3. functions that take parameters

3.带有参数的函数

i. mandatory parameters e.g

强制参数,例如

void greeting(@required String greeting){ 
print(greeting);
}

ii. optional parameters

ii 。 可选参数

  • optional positional parameter e.g

    可选的位置参数,例如

void details([int telephone]) {...}
  • optional named parameter e.g

    可选的命名参数,例如

void details({String firstName, String lastName}) {...}
  • optional parameter with default values e.g

    具有默认值的可选参数,例如

void details({int age: 30}) {...}
  • a function with all possible types of parameters:

    具有所有可能类型的参数的函数:
void details (int id, [int telephone],{String firstName, String lastName}, {int age: 30}) {...}

and you could call it with:

您可以通过以下方式调用它:

details(1001)details(1001, 078787878787, firstName: John, lastName: Ham, age: 50)

4. Getters and Setters

4.获取器和设置器

Special methods that provide read and write access to an object’s properties.

提供对对象属性的读写访问权限的特殊方法。

class Car {
String make;
Car({this.make});String get make => make;void set make(String name) => make = name;}

to call:

致电:

Car myCar = Car(‘Porsche’);print(myCar.make);

不同的函数声明: (Different Function declarations:)

  1. Regular function e.g

    常规功能,例如
void greeting { 
print(‘hello’);
}

2. Lambda function/arrow function is a short form of a regular function that can only return one expression. (Arrows instead of curly brackets). e.g

2. Lambda函数/箭头函数是正则函数的缩写,只能返回一个表达式。 (用箭头代替大括号)。 例如

void greeting => print(‘hello’);

翻译自: https://medium.com/the-innovation/flutter-different-types-of-functions-e92461371660

css 颤动

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值