当前位置:网站首页>[fluent] dart function (function composition | private function | anonymous function | function summary)
[fluent] dart function (function composition | private function | anonymous function | function summary)
2022-07-02 20:22:00 【Programmer community】
List of articles
- One 、Dart Function constitution
- Two 、Dart Private functions
- 3、 ... and 、Dart Anonymous functions
- Four 、 Complete code example
- 5、 ... and 、Dart Methods to summarize
- 6、 ... and 、 Related resources
One 、Dart Function constitution
Dart Function constitution : Method name , Parameters , Return value ;
return type :
- ① default : The return value type can be defaulted ;
- ② Empty type : The return value type can be set to void ;
- ③ The real type : The return value type can be set to the real data type ;
Method name :
- ① Anonymous methods : No method name is required ;
- ② Common method : Methods other than anonymous methods require method names ;
Parameters :
- ① form : Parameters include Parameter type , Parameter name ;
- ② Type default : The parameter type can be defaulted ;
- ③ Parameter classification : Optional parameters , Default parameters ;
Examples of standard methods :
/// Standard method /// The return value is int type /// The function name is sum /// Parameter is int num1, int num2 int sum(int num1, int num2){
return num1 + num2; }Two 、Dart Private functions
Private method :
- brief introduction : Only methods that can be accessed in the current file are called private methods ;
- Format : Underline the method name , Identifies that the method is private ;
Private method example :
/// The method is private int _minus(int num1, int num2){
return num1 - num2; }3、 ... and 、Dart Anonymous functions
Anonymous methods : Only parameter list and method body , No method name , Anonymous methods can be assigned to a variable ,
Anonymous methods And Naming method Corresponding , The common way is to name ;
The anonymous method format is as follows : In parentheses is a list of parameters , In braces is the method body ;
( Parameter type Parameter name , Parameter type 2 Parameter name 2){
/// Anonymous method body };Anonymous method example :
/// Anonymous method example anonymousFunction(){
var list = ['Tom', 'Jerry']; list.forEach( /// The following method is anonymous , Only parameter list and method body (i){
print(list.indexOf(i)); } ); }Four 、 Complete code example
class Function{
/// Standard method /// The return value is int type /// The function name is sum /// Parameter is int num1, int num2 int sum(int num1, int num2){
return num1 + num2; } /// The method is private int _minus(int num1, int num2){
return num1 - num2; } /// Anonymous method example anonymousFunction(){
var list = ['Tom', 'Jerry']; list.forEach( /// The following method is anonymous , Only parameter list and method body (i){
print(list.indexOf(i)); } ); }}5、 ... and 、Dart Methods to summarize
Entry method : stay main.dart Medium main() Method ;
void main() => runApp(MyApp());Construction method : Reference resources 【Flutter】Dart object-oriented ( Name the construction method | Factory construction method | Name factory construction method ) Naming construction method in blog , Factory construction method, etc ;
getter and setter Method : Use get and set How to define keywords , Reference resources 【Flutter】Dart object-oriented ( get Method | set Method | Static methods ) Blog ;
Static methods : static Methods of keyword modification ; Reference resources 【Flutter】Dart object-oriented ( get Method | set Method | Static methods ) Blog ;
Abstract method : There is no method body method ; Reference resources 【Flutter】Dart object-oriented ( abstract class | Abstract method ) Blog ;
Private method : Method names begin with an underscore ;
Anonymous methods : Only parameter list and method body , No method name ;
6、 ... and 、 Related resources
Reference material :
- Flutter Official website : https://flutter.dev/
- Flutter Developing documents : https://flutter.cn/docs ( Strongly recommend )
- official GitHub Address : https://github.com/flutter
- Flutter The Chinese community : https://flutter.cn/
- Flutter Practical tutorial : https://flutter.cn/docs/cookbook
- Flutter CodeLab : https://codelabs.flutter-io.cn/
- Dart Chinese document : https://dart.cn/
- Dart Developer website : https://api.dart.dev/
- Flutter Chinese net ( unofficial , The translation is very good ) : https://flutterchina.club/ , http://flutter.axuer.com/docs/
- Flutter Related issues : https://flutterchina.club/faq/ ( It is recommended to watch it at the introductory stage )
Blog source download :
GitHub Address : https://github.com/han1202012/flutter_app_hello ( Keep updating with the progress of the blog , There may not be the source code of this blog )
Blog source snapshot : https://download.csdn.net/download/han1202012/15452191 ( The source code snapshot of this blog , You can find the source code of this blog )
边栏推荐
- for(auto a : b)和for(auto &a : b)用法
- NMF-matlab
- What are the benefits of multi terminal applet development? Covering Baidu applet, Tiktok applet, wechat applet development, and seizing the multi platform traffic dividend
- upload-labs
- [source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
- Shardingsphere jdbc5.1.2 about select last_ INSERT_ ID () I found that there was still a routing problem
- Common problems and description of kt148a voice chip IC development
- 【Hot100】21. 合并两个有序链表
- [real case] trap of program design - beware of large data
- [daily question] 241 Design priorities for operational expressions
猜你喜欢
In depth understanding of modern web browsers (I)

Jetson XAVIER NX上ResUnet-TensorRT8.2速度與顯存記錄錶(後續不斷補充)

Notes on hardware design of kt148a voice chip IC

CRM Customer Relationship Management System

Istio deployment: quickly start microservices,

Summary of interview experience, escort your offer, full of knowledge points

Driverless learning (4): Bayesian filtering

C language linked list -- to be added

upload-labs

After writing 100000 lines of code, I sent a long article roast rust
随机推荐
Resunnet - tensorrt8.2 Speed and Display record Sheet on Jetson Xavier NX (continuously supplemented)
In depth understanding of modern web browsers (I)
勵志!大凉山小夥全獎直博!論文致謝看哭網友
Common problems and description of kt148a voice chip IC development
【JS】获取hash模式下URL的搜索参数
Why do I have a passion for process?
Exemple complet d'enregistrement du modèle pytoch + enregistrement du modèle pytoch seuls les paramètres d'entraînement sont - ils enregistrés? Oui (+ Solution)
What are the benefits of multi terminal applet development? Covering Baidu applet, Tiktok applet, wechat applet development, and seizing the multi platform traffic dividend
Database schema notes - how to choose the right database in development + who invented relational database?
AcWing 1129. Heat wave solution (shortest path SPFA)
Motivation! Big Liangshan boy a remporté le prix Zhibo! Un article de remerciement pour les internautes qui pleurent
Postman接口测试实战,这5个问题你一定要知道
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
AcWing 181. Turnaround game solution (search ida* search)
编写完10万行代码,我发了篇长文吐槽Rust
通信人的经典语录,第一条就扎心了……
How to realize the function of detecting browser type in Web System
B-end e-commerce - reverse order process
AcWing 1128. Messenger solution (shortest path Floyd)
数据库模式笔记 --- 如何在开发中选择合适的数据库+关系型数据库是谁发明的?