text
stringlengths
1
372
adjusting text spacing
in CSS, you specify the amount of white space
between each letter or word by giving a length value
for the letter-spacing and word-spacing properties, respectively.
the amount of space can be in px, pt, cm, em, etc.
in flutter, you specify white space as logical pixels
(negative values are allowed)
for the letterSpacing and wordSpacing properties
of a TextStyle child of a text widget.
<topic_end>
<topic_start>
making inline formatting changes
a text widget lets you display text
with some formatting characteristics.
to display text that uses multiple styles
(in this example, a single word with emphasis),
use a RichText widget instead.
its text property can specify one or more
TextSpan objects that can be individually styled.
in the following example, “lorem” is in a TextSpan
with the default (inherited) text styling,
and “ipsum” is in a separate TextSpan with custom styling.
<topic_end>
<topic_start>
creating text excerpts
an excerpt displays the initial line(s) of text in a paragraph,
and handles the overflow text, often using an ellipsis.
in flutter, use the maxLines property of a text widget
to specify the number of lines to include in the excerpt,
and the overflow property for handling overflow text.
<topic_end>
<topic_start>
flutter for Xamarin.Forms developers
this document is meant for Xamarin.Forms developers
looking to apply their existing knowledge
to build mobile apps with flutter.
if you understand the fundamentals of the Xamarin.Forms framework,
then you can use this document as a jump start to flutter development.
your android and iOS knowledge and skill set
are valuable when building with flutter,
because flutter relies on the native operating system configurations,
similar to how you would configure your native Xamarin.Forms projects.
the flutter frameworks is also similar to how you create a single UI,
that is used on multiple platforms.
this document can be used as a cookbook by jumping around
and finding questions that are most relevant to your needs.
<topic_end>
<topic_start>
project setup
<topic_end>
<topic_start>
how does the app start?
for each platform in Xamarin.Forms,
you call the LoadApplication method,
which creates a new application and starts your app.
in flutter, the default main entry point is
main where you load your flutter app.
<code_start>
void main() {
runApp(const MyApp());
}
<code_end>
in Xamarin.Forms, you assign a page to the
MainPage property in the application class.
in flutter, “everything is a widget”, even the application itself.
the following example shows MyApp, a simple application widget.
<code_start>
class MyApp extends StatelessWidget {
/// this widget is the root of your application.
const MyApp({super.key});
@override
widget build(BuildContext context) {
return const center(
child: text(
'hello world!',
textDirection: TextDirection.ltr,
),
);
}
}
<code_end>
<topic_end>
<topic_start>
how do you create a page?
Xamarin.Forms has many types of pages;
ContentPage is the most common.
in flutter, you specify an application widget that holds your root page.
you can use a MaterialApp widget, which supports material design,
or you can use a CupertinoApp widget, which supports an iOS-style app,
or you can use the lower level WidgetsApp,
which you can customize in any way you want.
the following code defines the home page, a stateful widget.
in flutter, all widgets are immutable,
but two types of widgets are supported: stateful and stateless.
examples of a stateless widget are titles, icons, or images.
the following example uses MaterialApp,
which holds its root page in the home property.
<code_start>
class MyApp extends StatelessWidget {
/// this widget is the root of your application.