text stringlengths 1 372 |
|---|
), |
); |
} |
} |
<code_end> |
info note |
the cupertino library implements widgets that follow |
apple’s human interface guidelines for iOS. |
when designing your UI, you can use |
widgets from the standard widgets library, or the cupertino 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> |
Non-Material apps |
for a non-Material app, you can add the center widget to the app’s |
build() method: |
<code_start> |
class MyApp extends StatelessWidget { |
const MyApp({super.key}); |
@override |
widget build(BuildContext context) { |
return container( |
decoration: const BoxDecoration(color: colors.white), |
child: const center( |
child: text( |
'hello world', |
textDirection: TextDirection.ltr, |
style: TextStyle( |
fontSize: 32, |
color: colors.black87, |
), |
), |
), |
); |
} |
} |
<code_end> |
by default, a non-Material app doesn’t include an AppBar, title, |
or background color. if you want these features in a non-Material app, |
you have to build them yourself. this app changes the background |
color to white and the text to dark grey to mimic a material app. |
that’s it! when you run the app, you should see hello world. |
app source code: |
<topic_end> |
<topic_start> |
lay out multiple widgets vertically and horizontally |
one of the most common layout patterns is to arrange |
widgets vertically or horizontally. you can use a |
row widget to arrange widgets horizontally, |
and a column widget to arrange widgets vertically. |
<topic_end> |
<topic_start> |
what's the point? |
to create a row or column in flutter, you add a list of children |
widgets to a row or column widget. in turn, |
each child can itself be a row or column, and so on. |
the following example shows how it is possible to nest rows or |
columns inside of rows or columns. |
this layout is organized as a row. the row contains two children: |
a column on the left, and an image on the right: |
the left column’s widget tree nests rows and columns. |
you’ll implement some of pavlova’s layout code in |
nesting rows and columns. |
info note |
row and column are basic primitive widgets for horizontal |
and vertical layouts—these low-level widgets allow for maximum |
customization. flutter also offers specialized, higher level widgets |
that might be sufficient for your needs. for example, |
instead of row you might prefer ListTile, |
an easy-to-use widget with properties for leading and trailing icons, |
and up to 3 lines of text. instead of column, you might prefer |
ListView, a column-like layout that automatically scrolls |
if its content is too long to fit the available space. |
for more information, see common layout widgets. |
<topic_end> |
<topic_start> |
aligning widgets |
you control how a row or column aligns its children using the |
mainAxisAlignment and crossAxisAlignment properties. |
for a row, the main axis runs horizontally and the cross axis runs |
vertically. for a column, the main axis runs vertically and the cross |
axis runs horizontally. |
the MainAxisAlignment and CrossAxisAlignment |
enums offer a variety of constants for controlling alignment. |
info note |
when you add images to your project, |
you need to update the pubspec.yaml file to access |
them—this example uses image.asset to display |
the images. for more information, see this example’s |
pubspec.yaml file or adding assets and images. |
you don’t need to do this if you’re referencing online |
images using image.network. |
in the following example, each of the 3 images is 100 pixels wide. |
the render box (in this case, the entire screen) |
is more than 300 pixels wide, so setting the main axis |
alignment to spaceEvenly divides the free horizontal |
space evenly between, before, and after each image. |
app source: row_column |
columns work the same way as rows. the following example shows a column |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.