0

I want to print specific part of String in dart Example:

String sample = "Hello World";

Output:

llo Wor

Like In Python We do this simply By:

print(sample[2:-2])

But How to achieve this in Dart Language

If you know the Solution then answer this question.

3 Answers 3

1

use substring

String sample = "Hello World";

Output:

llo Wor

code in dart

print(sample.substring(2, 9));
Sign up to request clarification or add additional context in comments.

Comments

1

You Can Do this With substring Method In Dart Like This:

String sample = "hello world";
print(sample.subString(2,7);

if You want to Specify Number of Letters From End Then Do This.

print(sample.subString(2,sample.length-2);

Comments

0

You can simply use the substring method.

like so:

print(helloWorldText.substring(2, helloWorldText.length -2));

Here is the example in Dartpad.
https://dartpad.dev/c15474ddb5402fef40e73332a41642cd?null_safety=true

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.