Dart String Ends With method

Last Updated On Friday 27th Aug 2021

The dart endsWith() is used to check if a string ends with a given String value.

  • One thing to remember the endsWith() method is Case sensitive.
	void main() {
  String sttrr = "Hello World";

  print(sttrr.endsWith("d"));
}
	

The Above Function Prints true.Coz it Ends with letter d.

	void main() {
  String sttrr = "Hello Mars";

  print(sttrr.endsWith("d"));
}
	

The Above Function Prints false.Coz it doesn’t ends with d.

  • We can also use the endsWith() method with multiple letters.
	void main() {
  String sttrr = "Hello World";

  print(sttrr.endsWith("ld"));
}
	

The Above Prints the value true.It Consists the ld.