Widget Stack not showing top levels

0 votes

I made the Stack widget as usual, but the InkWell widget didn't appear on top of the blue Container. For the experiment, I put other widgets in its place and everything works. What did I do wrong? Here is the part of the code:

          Stack(
            children: [
            Container(height: 280, color: Colors.blue,),
            Row(
              children: [
                InkWell(
                  onTap: () {
                    Navigator.of(context).pushReplacement(
                        MaterialPageRoute(
                            builder: (context) =>
                                Mainpage()));
                  }, 
                  splashColor: Colors.brown.withOpacity(0.5),
                  child: Ink(
                    height: 48,
                    width: 48,
                    decoration: const BoxDecoration(
                      image: DecorationImage(
                        image:
                        AssetImage('assets/dagger.png'),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                ),
              ],
            ),
Apr 3, 2023 in Flutter by sarit
• 1,830 points
1,103 views

1 answer to this question.

0 votes

Based on the code you provided, it seems like the InkWell widget is being wrapped inside a Row widget, which could be causing it to not show up on top of the blue Container. The InkWell widget needs to be a direct child of the Stack widget in order to be positioned on top of the blue Container.

Try removing the Row widget and placing the InkWell widget directly inside the Stack widget. Here's an updated code snippet:

Stack(
  children: [
    Container(height: 280, color: Colors.blue),
    InkWell(
      onTap: () {
        Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context) => Mainpage()));
      },
      splashColor: Colors.brown.withOpacity(0.5),
      child: Ink(
        height: 48,
        width: 48,
        decoration: const BoxDecoration(
          image: DecorationImage(
            image: AssetImage('assets/dagger.png'),
            fit: BoxFit.cover,
          ),
        ),
      ),
    ),
  ],
),

This should position the InkWell widget on top of the blue Container.

answered Apr 3, 2023 by Nidhi

Related Questions In Flutter

0 votes
1 answer
0 votes
1 answer

Flutter position stack widget in center

To center the ButtonBar widget at the ...READ MORE

answered Mar 29, 2023 in Flutter by seena
3,464 views
0 votes
1 answer

What is the use of Material Widget?

The Material widget is a key component ...READ MORE

answered Mar 21, 2023 in Flutter by pooja
1,311 views
0 votes
1 answer

Run method on Widget build complete

You can use the WidgetsBindingObserver to be ...READ MORE

answered Mar 24, 2023 in Flutter by vijitha
1,439 views
0 votes
1 answer

Dart_LoadScriptFromKernel: The binary program does not contain 'main'.

Hi@akhtar, You need to add the main() function ...READ MORE

answered Jul 21, 2020 in Others by MD
• 95,460 points
3,561 views
0 votes
1 answer

How to install Dart in Windows system?

Hi@akhtar, Dart is the programming language used to code Flutter apps. ...READ MORE

answered Jul 21, 2020 in Others by MD
• 95,460 points
1,117 views
0 votes
1 answer

flutter run: No connected devices

Hi@akhtar, To prepare to run and test your ...READ MORE

answered Jul 21, 2020 in Others by MD
• 95,460 points
4,122 views
0 votes
1 answer

How to create a function in Dart language?

Hi@akhtar, There are many function types available in ...READ MORE

answered Jul 22, 2020 in Others by MD
• 95,460 points
753 views
0 votes
1 answer

Flutter command not found

This error message usually appears when the ...READ MORE

answered Mar 29, 2023 in Flutter by vishalini
17,837 views
0 votes
1 answer

Xcode Cloud not building my Flutter Project

It's difficult to determine the exact cause ...READ MORE

answered Apr 11, 2023 in Flutter by Anitha
1,869 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP