Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Formatting for the Footer #203

Open
phillipshaong opened this issue Dec 4, 2023 · 1 comment
Open

Bug: Formatting for the Footer #203

phillipshaong opened this issue Dec 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@phillipshaong
Copy link

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 phillipshaong added the bug Something isn't working label Dec 4, 2023
@chriscdn
Copy link

I believe this is caused by the crossAxisAlignment being set to CrossAxisAlignment.stretch.

crossAxisAlignment: CrossAxisAlignment.stretch,

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants