introduction_screen
introduction_screen copied to clipboard
Bug: Formatting for the Footer
Describe the bug A clear and concise description of what the bug is.
The footer expands to the horizontal ends of the screen. There isn't a way to constrain the width.
To Reproduce Steps to reproduce the behavior:
- Create any generic
IntroductionScreenwidget. - Add to the following
PageViewModelto thepagesargument ofIntroductionScreen:
PageViewModel(
title: "This is a title", //"Welcome to KarmaKard",
body:
"This is a body", //"Where good deeds are rewarded with good deals.",
image: _buildImage('community.png', 600),
decoration: pageDecoration,
footer: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 300),
child: ElevatedButton(
onPressed: () {
introKey.currentState?.animateScroll(0);
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
child: Text(
'Continue',
style:
TextStyle(color: Theme.of(context).colorScheme.onPrimary),
),
),
),
),
Expected behavior The button should be constrained to the max width.
Screenshots
Additional context This is on Chrome, for flutter web.
I believe this is caused by the crossAxisAlignment being set to CrossAxisAlignment.stretch.
https://github.com/Pyozer/introduction_screen/blob/ed7fc561cc2fe4beb57319dfcbdeb8cf05221cd6/lib/src/ui/intro_page.dart#L85
Try wrapping your button in a Center, which will render the button at its intrinsic size. E.g.,
PageViewModel(
title: "This is a title", //"Welcome to KarmaKard",
body:
"This is a body", //"Where good deeds are rewarded with good deals.",
image: _buildImage('community.png', 600),
decoration: pageDecoration,
footer: Center(
child: ElevatedButton(
onPressed: () {
introKey.currentState?.animateScroll(0);
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
child: Text(
'Continue',
style:
TextStyle(color: Theme.of(context).colorScheme.onPrimary),
),
),
),
)