text stringlengths 1 372 |
|---|
expanded( |
/*1*/ |
child: column( |
crossAxisAlignment: CrossAxisAlignment.start, |
children: [ |
/*2*/ |
padding( |
padding: const EdgeInsets.only(bottom: 8), |
child: text( |
name, |
style: const TextStyle( |
fontWeight: FontWeight.bold, |
), |
), |
), |
text( |
location, |
style: TextStyle( |
color: colors.grey[500], |
), |
), |
], |
), |
), |
/*3*/ |
icon( |
icons.star, |
color: colors.red[500], |
), |
const text('41'), |
], |
), |
); |
} |
} |
<code_end> |
<topic_end> |
<topic_start> |
change the app body to a scrolling view |
in the body property, replace the center widget with a |
SingleChildScrollView widget. |
within the SingleChildScrollView widget, replace the text widget with a |
column widget. |
these code updates change the app in the following ways. |
<topic_end> |
<topic_start> |
update the app to display the title section |
add the TitleSection widget as the first element in the children list. |
this places it at the top of the screen. |
pass the provided name and location to the TitleSection constructor. |
lightbulb tip |
<topic_end> |
<topic_start> |
add the button section |
in this section, add the buttons that will add functionality to your app. |
the button section contains three columns that use the same layout: |
an icon over a row of text. |
plan to distribute these columns in one row so each takes the same |
amount of space. paint all text and icons with the primary color. |
<topic_end> |
<topic_start> |
add the ButtonSection widget |
add the following code after the TitleSection widget to contain the code |
to build the row of buttons. |
<code_start> |
class ButtonSection extends StatelessWidget { |
const ButtonSection({super.key}); |
@override |
widget build(BuildContext context) { |
final color color = Theme.of(context).primaryColor; |
// ··· |
} |
} |
<code_end> |
<topic_end> |
<topic_start> |
create a widget to make buttons |
as the code for each column could use the same syntax, |
create a widget named ButtonWithText. |
the widget’s constructor accepts a color, icon data, and a label for the button. |
using these values, the widget builds a column with an icon and a stylized |
text widget as its children. |
to help separate these children, a padding widget the text widget |
is wrapped with a padding widget. |
add the following code after the ButtonSection class. |
<code_start> |
class ButtonSection extends StatelessWidget { |
const ButtonSection({super.key}); |
// ··· |
} |
class ButtonWithText extends StatelessWidget { |
const ButtonWithText({ |
super.key, |
required this.color, |
required this.icon, |
required this.label, |
}); |
final color color; |
final IconData icon; |
final string label; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.