introduction_screen icon indicating copy to clipboard operation
introduction_screen copied to clipboard

Bug: Formatting for the Footer

Open phillipshaong opened this issue 2 years ago • 1 comments

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:

  1. Create any generic IntroductionScreen widget.
  2. Add to the following PageViewModel to the pages argument of IntroductionScreen:
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 image

Additional context This is on Chrome, for flutter web.

phillipshaong avatar Dec 04 '23 02:12 phillipshaong

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),
      ),
    ),
  ),
)

chriscdn avatar May 29 '24 05:05 chriscdn