It should be updated all the time in the future, I think. First of all, I will not state the future trend of flutter. It is impossible for java to be replaced by other languages in the future. It will still be the dominant language in China. It's not very meaningful to learn or not to learn flutter personally. After debating whether or not there is a flutter engineer, because every year the language is changing, you have to keep on learning, now flutter is the most suitable one. Learn slowly when you want to learn, after playing games. After all, it's hard to evolve into a better person when the time is not enough and the money is not enough.
Download the latest available installation packages on flutter's official website at: https://flutter.io/sdk-archive/#windows
Introduction to Dart Language: I feel it's very similar to C. C: c+java Dart:java+javascript belongs to "hybrid rice" and I can't help feeling it.
Var: Any type of variable is acceptable, but final
var t; t = "hi yun"; //The following code will report errors in dart because the type of variable t has been determined to be String, and the // type cannot be changed once it is determined. t = 10000;
2. Dynamics and Object: When you look at the same name as C #, it seems that you want to imitate and transcend, and you can see the code differently.
Same: dynamic t; Object x; t = ""; x = ""; //There is no problem with the following code t = 1001; x = 10002; //Different: dynamic a; Object b; main(){ a = ""; b = ""; printLengths(); } printLengths(){ // no warning print(a.length); // warning: // The getter 'length' is not defined for the class 'Object' print(b.length); }
3.final and const: A final variable can only be set once. The difference is that a const variable is a compile-time constant and a final variable is initialized the first time it is used. Variable types modified by final or const can be omitted, such as:
//String can be omitted as a type declaration final str = "yun"; final String str = "yun"; const str1 = "yun"; const String str1 = "yun";
4. Function declaration: even a function is an object, which is convenient.
//1. Function declaration bool isNoble(int aaaa){ return _nobleGases[aaaa]!=null; } //2.dart function declarations are treated as dynamic s by default if the return value type is not explicitly declared. Note that there is no type inference for the return value of the function: typedef bool CALLBACK(); //No return type is specified, which defaults to dynamic instead of bool isNoble(int bbbbb){ return _nobleGases[bbbbb]!=null; } void test(CALLBACK cb){ print(cb()); } //Error, isNoble is not bool type test(isNoble); //3. For functions that contain only one expression, abbreviation grammar can be used bool isNoble(int cccc)=>_nobleGases{cccc}!=null //4. Functions as variables var say = (str){ print(str); }; say("yun"); //5. Transfer of functions as parameters void execute(var callback){ callback(); } execute(()=>print("yun")) //6. Optional positional parameter: I like it very much. I feel comfortable writing this way in the future ~and I feel that there are many places that the $operator will need to use in the future _________~ String yun(String from,String msg,[String device]){ var result = '$from say $msg'; if(device!=null){ result = '$result with a $device'; } return result; } yun('geek','yun');//Result: geek says yun yun('geek','yun','heart');//Result: geek said yun with a heart //7. Optional naming parameters: How much will this be used later?~ void yun({bool yun1,bool yun2}){ // ...... } yun(yun1:false,yun2:true);
5. Asynchronous Support: This has been waiting for many years, and finally there is no need to write logic, mindless results-oriented to refresh the ui perfect ~So google's name is also poetic Future.
//1. Look at the basic way of writing first: Actually, what's more damaging is that it's really hard to find such a way of writing. Maybe it's because I'm not used to it yet.~ Future.delayed(new Duration(seconds: 2), () { return "hi yun~"; }).then((data) { print(data); }); //2. Asynchronous task error capture: Future.delayed(new Duration(seconds: 2), () { throw AssertionError("Yun Error"); }).then((data) { //Success in execution will come here print("yun success~"); }).catchError((e) { //Failure to execute will come here print(e); }); //3. You can also write catch errors like this: Future.delayed(new Duration(seconds: 2), () { throw AssertionError("yun error~"); }).then((data) { print("yun success~"); }, onError: (e) { print(e); }); //4. Future. When Complete: Pop-up the load dialog before the network request and close the dialog after the request ends Future.delayed(new Duration(seconds: 2), () { throw AssertionError("yun error~"); }).then((data) { //Success in execution will come here print(data); }).catchError((e) { //Failure to execute will come here // loading success print(e); }).whenComplete(() { //Success or failure will come here. // loading success }); //5.Future.wait: The classic is coming right away. Look carefully. It saves a lot of code. Future.wait([ //Return the result in 2 seconds Future.delayed(new Duration(seconds: 2), () { return "hi "; }), //Return results in 4 seconds Future.delayed(new Duration(seconds: 4), () { return "yun~"; }) ]).then((results) { //4 seconds later you will see "hi yun ~" in the console print(results[0] + results[1]); }).catchError((e) { print(e); }); //6.Async/await: The worst is coming. Is it comfortable that all the previous logic is now transitive? Future<String> login(String name, String pwd) { //User login returns id }; Future<String> getInfo(String id) { //Get user information and return info }; Future saveInfo(String info) { //Save it locally }; // 1 login("yun", "lx").then((id) { //After successful login, user information is obtained by id getInfo(id).then((info) { //Save after getting user information saveInfo(info).then((yun) { //Save user information, and then perform other operations }); }); }); // 2 login("yun", "lx").then((id) { return getInfo(id); }).then((info) { return saveInfo(info); }).then((e) { //Perform the next operation print(e); }).catchError((e) { //error handling print(e); }); // 3 task() async { try { String id = await login("yun", "lx"); String info = await getInfo(id); await saveInfo(info); //Perform the next operation } catch (e) { //error handling print(e); } } //7.Stream: Used in asynchronous task scenarios where data is read many times, such as downloading network content, reading and writing files, etc. Stream.fromFutures([ Future.delayed(new Duration(seconds: 1), () { return "hi yun1"; }), Future.delayed(new Duration(seconds: 2), () { throw AssertionError("yun error1"); }), Future.delayed(new Duration(seconds: 3), () { return "hi yun3"; }) ]).listen((data) { print(data); }, onError: (e) { print(e); }, onDone: () {}); //Results: hi yun1 Assertion failed hi yun3
Summary: There is not much to say today. I feel that flutter has a process to write. I wasn't very used to it at the beginning, but I got used to it. It's really java, let alone mine.~
Attachment: Objectively speaking, if you have time, you should learn more. After all, young people are best to make progress together with two people, with motivation, don't be too tired, just stick to it. I think the blog should continue to update. As for how far you can go in programming, see your mood, follow your heart, try not to let yourself regret things, love a truth, you don't learn. Miss is a lifetime, of course, not so hard to catch up with, follow the interest, so that the burden-free progress is life ~together refueling~