text
stringlengths 1
372
|
|---|
in terms of how they handle their constraints:
|
some widgets, for example container,
|
vary from type to type based on their constructor arguments.
|
the container constructor defaults
|
to trying to be as big as possible, but if you give it a width,
|
for instance, it tries to honor that and be that particular size.
|
others, for example row and column (flex boxes)
|
vary based on the constraints they are given,
|
as described in the flex section.
|
<topic_end>
|
<topic_start>
|
examples
|
for an interactive experience, use the following DartPad.
|
use the numbered horizontal scrolling bar to switch between
|
29 different examples.
|
<code_start>
|
import 'package:flutter/material.dart';
|
void main() => runApp(const HomePage());
|
const red = colors.red;
|
const green = colors.green;
|
const blue = colors.blue;
|
const big = TextStyle(fontSize: 30);
|
//////////////////////////////////////////////////
|
class HomePage extends StatelessWidget {
|
const HomePage({super.key});
|
@override
|
widget build(BuildContext context) {
|
return const FlutterLayoutArticle([
|
example1(),
|
example2(),
|
example3(),
|
example4(),
|
example5(),
|
example6(),
|
example7(),
|
example8(),
|
example9(),
|
example10(),
|
example11(),
|
example12(),
|
example13(),
|
example14(),
|
example15(),
|
example16(),
|
example17(),
|
example18(),
|
example19(),
|
example20(),
|
example21(),
|
example22(),
|
example23(),
|
example24(),
|
example25(),
|
example26(),
|
example27(),
|
example28(),
|
example29(),
|
]);
|
}
|
}
|
//////////////////////////////////////////////////
|
abstract class example extends StatelessWidget {
|
const example({super.key});
|
string get code;
|
string get explanation;
|
}
|
//////////////////////////////////////////////////
|
class FlutterLayoutArticle extends StatefulWidget {
|
const FlutterLayoutArticle(
|
this.examples, {
|
super.key,
|
});
|
final List<Example> examples;
|
@override
|
State<FlutterLayoutArticle> createState() => _FlutterLayoutArticleState();
|
}
|
//////////////////////////////////////////////////
|
class _FlutterLayoutArticleState extends State<FlutterLayoutArticle> {
|
late int count;
|
late widget example;
|
late string code;
|
late string explanation;
|
@override
|
void initState() {
|
count = 1;
|
code = const example1().code;
|
explanation = const example1().explanation;
|
super.initState();
|
}
|
@override
|
void didUpdateWidget(FlutterLayoutArticle oldWidget) {
|
super.didUpdateWidget(oldWidget);
|
var example = widget.examples[count - 1];
|
code = example.code;
|
explanation = example.explanation;
|
}
|
@override
|
widget build(BuildContext context) {
|
return MaterialApp(
|
debugShowCheckedModeBanner: false,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.