Skip to content

Instantly share code, notes, and snippets.

@misterfourtytwo
Last active January 11, 2023 17:52
Show Gist options
  • Save misterfourtytwo/f292388ccd7118300ca166635adbe705 to your computer and use it in GitHub Desktop.
Save misterfourtytwo/f292388ccd7118300ca166635adbe705 to your computer and use it in GitHub Desktop.
crossAxisAlignment.start vs stretch
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Align(
child: Container(
width: 600,
height: 300,
color: Colors.pink[200],
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Placeholder(
color: Colors.amber,
fallbackHeight: 100,
),
Divider(),
TextColumn(false),
Divider(),
Container(
decoration: BoxDecoration(color: Colors.amber),
child: TextColumn(false),
),
Divider(),
Container(
decoration: BoxDecoration(color: Colors.amber),
child: TextColumn(true),
),
Divider(),
Placeholder(
color: Colors.amber,
fallbackHeight: 100,
),
],
),
),
),
),
),
);
}
}
class TextColumn extends StatelessWidget {
final bool stretch;
const TextColumn(this.stretch);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment:
stretch ? CrossAxisAlignment.stretch : CrossAxisAlignment.start,
children: [
Text(
'Replenish Wallet to launch Ads',
),
const SizedBox(height: 12),
Text('The money will be stored in the wallet indefinitely.'
// ' The system will write off no more than your daily budget for Advertising',
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment