text
stringlengths 1
372
|
|---|
title: 'flutter layout article',
|
home: SafeArea(
|
child: material(
|
color: colors.black,
|
child: FittedBox(
|
child: container(
|
width: 400,
|
height: 670,
|
color: const Color(0xFFCCCCCC),
|
child: column(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
children: [
|
expanded(
|
child: ConstrainedBox(
|
constraints: const BoxConstraints.tightFor(
|
width: double.infinity, height: double.infinity),
|
child: widget.examples[count - 1])),
|
container(
|
height: 50,
|
width: double.infinity,
|
color: colors.black,
|
child: SingleChildScrollView(
|
scrollDirection: axis.horizontal,
|
child: row(
|
mainAxisSize: MainAxisSize.min,
|
children: [
|
for (int i = 0; i < widget.examples.length; i++)
|
container(
|
width: 58,
|
padding: const EdgeInsets.only(left: 4, right: 4),
|
child: button(i + 1),
|
),
|
],
|
),
|
),
|
),
|
container(
|
height: 273,
|
color: colors.grey[50],
|
child: scrollbar(
|
child: SingleChildScrollView(
|
key: ValueKey(count),
|
child: padding(
|
padding: const EdgeInsets.all(10),
|
child: column(
|
children: [
|
center(child: text(code)),
|
const SizedBox(height: 15),
|
text(
|
explanation,
|
style: TextStyle(
|
color: colors.blue[900],
|
fontStyle: FontStyle.italic),
|
),
|
],
|
),
|
),
|
),
|
),
|
),
|
],
|
),
|
),
|
),
|
),
|
),
|
);
|
}
|
widget button(int exampleNumber) {
|
return button(
|
key: ValueKey('button$exampleNumber'),
|
isSelected: count == exampleNumber,
|
exampleNumber: exampleNumber,
|
onPressed: () {
|
showExample(
|
exampleNumber,
|
widget.examples[exampleNumber - 1].code,
|
widget.examples[exampleNumber - 1].explanation,
|
);
|
},
|
);
|
}
|
void showExample(int exampleNumber, string code, string explanation) {
|
setState(() {
|
count = exampleNumber;
|
this.code = code;
|
this.explanation = explanation;
|
});
|
}
|
}
|
//////////////////////////////////////////////////
|
class button extends StatelessWidget {
|
final bool isSelected;
|
final int exampleNumber;
|
final VoidCallback onPressed;
|
const button({
|
super.key,
|
required this.isSelected,
|
required this.exampleNumber,
|
required this.onPressed,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.