text
stringlengths 1
372
|
|---|
return image.asset(
|
image,
|
fit: BoxFit.cover,
|
);
|
<code_end>
|
create an icon widget:
|
<code_start>
|
icon(
|
icons.star,
|
color: colors.red[500],
|
),
|
<code_end>
|
<topic_end>
|
<topic_start>
|
3. add the visible widget to the layout widget
|
all layout widgets have either of the following:
|
add the text widget to the center widget:
|
<code_start>
|
const center(
|
child: Text('Hello world'),
|
),
|
<code_end>
|
<topic_end>
|
<topic_start>
|
4. add the layout widget to the page
|
a flutter app is itself a widget, and most widgets have a build()
|
method. instantiating and returning a widget in the app’s build() method
|
displays the widget.
|
<topic_end>
|
<topic_start>
|
material apps
|
for a material app, you can use a scaffold widget;
|
it provides a default banner, background color,
|
and has API for adding drawers, snack bars, and bottom sheets.
|
then you can add the center widget directly to the body
|
property for the home page.
|
<code_start>
|
class MyApp extends StatelessWidget {
|
const MyApp({super.key});
|
@override
|
widget build(BuildContext context) {
|
const string appTitle = 'flutter layout demo';
|
return MaterialApp(
|
title: appTitle,
|
home: scaffold(
|
appBar: AppBar(
|
title: const Text(appTitle),
|
),
|
body: const center(
|
child: Text('Hello world'),
|
),
|
),
|
);
|
}
|
}
|
<code_end>
|
info note
|
the material library implements widgets that follow material
|
design principles. when designing your UI, you can exclusively use
|
widgets from the standard widgets library, or you can use
|
widgets from the material library. you can mix widgets from both
|
libraries, you can customize existing widgets,
|
or you can build your own set of custom widgets.
|
<topic_end>
|
<topic_start>
|
cupertino apps
|
to create a cupertino app, use CupertinoApp and CupertinoPageScaffold widgets.
|
unlike material, it doesn’t provide a default banner or background color.
|
you need to set these yourself.
|
to add an iOS-styled navigation bar to the top of your app, add a
|
CupertinoNavigationBar widget to the navigationBar
|
property of your scaffold.
|
you can use the colors that CupertinoColors provides to
|
configure your widgets to match iOS design.
|
to learn what other UI components you can add, check out the
|
cupertino library.
|
<code_start>
|
class MyApp extends StatelessWidget {
|
const MyApp({super.key});
|
@override
|
widget build(BuildContext context) {
|
return const CupertinoApp(
|
title: 'flutter layout demo',
|
theme: CupertinoThemeData(
|
brightness: brightness.light,
|
primaryColor: CupertinoColors.systemBlue,
|
),
|
home: CupertinoPageScaffold(
|
navigationBar: CupertinoNavigationBar(
|
backgroundColor: CupertinoColors.systemGrey,
|
middle: Text('Flutter layout demo'),
|
),
|
child: center(
|
child: column(
|
mainAxisAlignment: MainAxisAlignment.center,
|
children: <widget>[
|
Text('Hello world'),
|
],
|
),
|
),
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.