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 in Flutter by sarit
• 1,430 points
127 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 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 in Flutter by seena
182 views
0 votes
1 answer

What is the use of Material Widget?

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

answered Mar 21 in Flutter by pooja
109 views
0 votes
1 answer

Run method on Widget build complete

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

answered Mar 24 in Flutter by vijitha
100 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,440 points
2,769 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,440 points
576 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,440 points
3,446 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,440 points
343 views
0 votes
1 answer

Flutter command not found

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

answered Mar 29 in Flutter by vishalini
759 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 in Flutter by Anitha
366 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