Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

This article also participated in the “Digitalstar Project” to win a creative gift package and creative incentive money.

📝 [Flutter] learning to form a record, [programmer essential knowledge]

📔 — The basic use of String for Dart data type Flutter!

1. Write at the front

In the previous article, I introduced the numeric type (num) of Dart’s basic data types, int and double. Now let’s move on to the basic SYNTAX for Dart, the string type.

The Apple Mac is configured with the Flutter development environment

Android Studio installs a third-party simulator for Flutter — netease MuMu

Failed to find Build Tools Revision 29.0.2

Android license status unknown. Run ‘Flutter doctor — Android – Licenses’

How to create a Flutter project and run your first Flutter project

Dart uses var, final, and const

Dart Indicates the num of the data type

2. String String

2.1 Basic Definitions

The string can use either single or double quotation marks. The test code is as follows:

void stingTest(a){
  var a = 'jay';
  var b = "reno";
  print(a+b);
}
Copy the code

The running results are as follows:

2.2 String Concatenation

Strings can be directly added for concatenation, or strings can be directly used as strings, as follows:

void stingTest(a){
  var a = 'jay';
  var b = "reno";
  print(a+b);

  String name = 'reno';
  print(name);
}
Copy the code

The code results are as follows:

2.3 Multi-line Strings

Triple and double quotation marks can display multi-line strings as follows:

void stingTest(a){
  String name = 'reno';
  print(name);
  // Triple and double quotation marks can display multi-line strings
  String name1 =
      "zjp\n"
      "jay\n"
      "reno\n";
  print(name1);

  String name2 = ' ' 'zjp
  jay 
  reno1
  
  ' ' ';
  print(name2);
}
Copy the code

The print result is as follows:

Three quotesThe will of theThe blank spaceAlso print out, restore the original string format, according to the format output.

2.4 Obtain the specified subscript character

Strings can also take specified characters, just as conveniently as arrays.

2.5 String Multiplication

Interestingly, strings can also be added and multiplied, but not subtracted and divided.

2.6 Output in String format

The output format of the string is as follows:The expression for formatted output is:${expression}If there is only one variable and no expression, remove the two large curly braces.

There are also some common methods, such as the length of the string, what the string begins and ends with, and so on.

Command + left-click to view method comments and usage, and click to see more string-related methods.

\n is normally an escape character – a newline character. After an r is added to the beginning of the string, it is not an escape character and becomes part of the string.

3. Write in the back

Follow me, more content continues to output

  • CSDN
  • The Denver nuggets
  • Jane’s book

🌹 if you like, give it a thumbs up 👍🌹

🌹 feel harvest, can come to a wave of collection + attention, so as not to find you next time I 😁🌹

🌹 welcome everyone to leave a message exchange, criticism and correction, forwarding please indicate the source, thank you for your support! 🌹