Polish the texture example (#157176)

Replaces `SizedBox`es with the new `spacing` parameter in `Column` and fixes some minor formatting issues.

This is a refactoring with no semantic changes. I will get a test exemption.
This commit is contained in:
Loïc Sharma 2024-10-21 09:54:04 -07:00 committed by GitHub
parent a4280f9396
commit 4ff8c9507b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,53 +35,54 @@ class _TexturePageState extends State<TexturePage> {
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 10,
children: <Widget>[
FutureBuilder<int?>(
future: textureId,
builder: (BuildContext context, AsyncSnapshot<int?> snapshot) {
if (snapshot.hasData) {
if (snapshot.data != null) {
return SizedBox(
width: textureWidth.toDouble(),
height: textureHeight.toDouble(),
child: Texture(textureId: snapshot.data!),
);
} else {
return const Text('Error creating texture');
}
} else {
if (!snapshot.hasData) {
return const Text('Creating texture...');
}
if (snapshot.data == null) {
return const Text('Error creating texture');
}
return SizedBox(
width: textureWidth.toDouble(),
height: textureHeight.toDouble(),
child: Texture(textureId: snapshot.data!),
);
},
),
const SizedBox(height: 10),
OutlinedButton(
child: const Text('Flutter Navy'),
onPressed: () => setColor(0x04, 0x2b, 0x59)),
const SizedBox(height: 10),
child: const Text('Flutter Navy'),
onPressed: () => setColor(0x04, 0x2b, 0x59),
),
OutlinedButton(
child: const Text('Flutter Blue'),
onPressed: () => setColor(0x05, 0x53, 0xb1)),
const SizedBox(height: 10),
child: const Text('Flutter Blue'),
onPressed: () => setColor(0x05, 0x53, 0xb1),
),
OutlinedButton(
child: const Text('Flutter Sky'),
onPressed: () => setColor(0x02, 0x7d, 0xfd)),
const SizedBox(height: 10),
child: const Text('Flutter Sky'),
onPressed: () => setColor(0x02, 0x7d, 0xfd),
),
OutlinedButton(
child: const Text('Red'),
onPressed: () => setColor(0xf2, 0x5d, 0x50)),
const SizedBox(height: 10),
child: const Text('Red'),
onPressed: () => setColor(0xf2, 0x5d, 0x50),
),
OutlinedButton(
child: const Text('Yellow'),
onPressed: () => setColor(0xff, 0xf2, 0x75)),
const SizedBox(height: 10),
child: const Text('Yellow'),
onPressed: () => setColor(0xff, 0xf2, 0x75),
),
OutlinedButton(
child: const Text('Purple'),
onPressed: () => setColor(0x62, 0x00, 0xee)),
const SizedBox(height: 10),
child: const Text('Purple'),
onPressed: () => setColor(0x62, 0x00, 0xee),
),
OutlinedButton(
child: const Text('Green'),
onPressed: () => setColor(0x1c, 0xda, 0xc5)),
child: const Text('Green'),
onPressed: () => setColor(0x1c, 0xda, 0xc5),
),
],
),
),