From 4ff8c9507bcf576a462fa26681414c34ee52cec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sharma?= <737941+loic-sharma@users.noreply.github.com> Date: Mon, 21 Oct 2024 09:54:04 -0700 Subject: [PATCH] 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. --- examples/texture/lib/main.dart | 65 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/examples/texture/lib/main.dart b/examples/texture/lib/main.dart index 2f0cc7eed3..78e5fda6a6 100644 --- a/examples/texture/lib/main.dart +++ b/examples/texture/lib/main.dart @@ -35,53 +35,54 @@ class _TexturePageState extends State { body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, + spacing: 10, children: [ FutureBuilder( future: textureId, builder: (BuildContext context, AsyncSnapshot 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), + ), ], ), ),