Reputation: 131
How do I write quotation marks in a text inside do:
ex: child: Text ("One fine day I woke up from" Bad Mood "was Monday"),
Container(
color: Colors.white,
height: 50,
width: 390,
margin: EdgeInsets.only(left: 15.0, top: 15.0, right: 15.0, bottom: 5.0 ),
alignment: Alignment.topRight,
child: Text ("2 لا تتطلب النية قول أي شيء بصوت عال، ولكن التركيز على عبارة "بسم الله".", textDirection: TextDirection.rtl,
style: TextStyle(
decoration: TextDecoration.none,
fontSize: 25.0,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
color: Colors.black,
),),
),
Upvotes: 13
Views: 24635
Reputation: 3688
Use 'dart_quote'
There two types of quotes.
Quote as a Widget
WidgetQuote(
text: 'This is the sample text including Quotes.',
).quote()
Quote in String
StringQuote(
text: 'This is the sample text including Quotes.',
).quote()
Upvotes: -1
Reputation: 71623
Dart strings literals have several ways to include quotes in a string.
There are three ways Dart string literals can vary:
'
) or double quotes ("
).r
) or interpolated (not prefixed by r
).All eight combinations can be used:
"A string ${withInterpolation}"
'A string ${withInterpolation}'
"""A string ${withInterpolation} (can contain newlines)"""
'''A string ${withInterpolation} (can contain newlines)'''
r"A raw string, $ means nothing"
r'A raw string, $ means nothing'
r"""A raw string, $ means nothing (can contain newlines)"""
r'''A raw string, $ means nothing (can contain newlines)'''
You cannot include the string delimiter inside the string without escaping it. Escapes use \
to ensure that the next quote character is used as string content, not a delimiter, but escapes do not work in raw strings—in a raw string, a \
is just a \
character, like a $
is just a character and not an interpolation starter.
So, to include a "
in a string, you can either use an escape, or use a delimiter other than "
. This rules out only a r" ... "
string which uses "
as delimiter and cannot use escapes.
"a \"quoted\" text."
'a "quoted" text.'
"""a "quoted" text."""
.r" ... "
.This gives you a lot of flexibility in writing strings. Using a raw "multi-line" string for its tripple-quote, even if it doesn't actually span multiple lines, allows you to have both quote characters and dollar/backslash in a string, like:
var complexString = r"""I don't know if "amazing" is what I'd call this $-price""";
You are only stuck if you need a raw string that contains both """
and '''
sequences. In that case, Dart combines two adjacent string literals, even with different quotes:
var veryComplexString =
r"""Dart strings start with ", r", ', r', """
r'""", r""", '
r"''', and r'''";
Finally, you can also use interpolations to include strings of other kinds:
var someStrings = "This string contains a ${'"'} quote character";
Upvotes: 22
Reputation: 14315
child: Text ('One fine day I woke up from" Bad Mood "was Monday'),
Reference : Difference between single and double quotes in Flutter/Dart
Upvotes: 7
Reputation: 107
Use
child: Text ("One fine day I woke up from\" Bad Mood \"was Monday"),
Upvotes: 4