tailor
tailor

Reputation: 443

How to set image in bottom right corner in container in flutter?

My first question is how to set image in bottom right corner, and the answer is

Align(
              alignment: Alignment.bottomRight,
              child: (Image(image: AssetImage("images/bg_decore_up_la.png"),)),
            ),

It is working fine, But in parent Scaffold I set

resizeToAvoidBottomInset: true,

means scroll is happening when keyboard is appear. For this , This Align (image) widget i set out of SingleChildScrollView

Now my whole code like

Scaffold(
        resizeToAvoidBottomInset: true,
        appBar:AppBar(),
        body:SafeArea(
            child:Stack(
                children:[
                  Align(
                    alignment: Alignment.bottomRight,
                    child: (Image(image: AssetImage("images/bg_decore_up_la.png"),)),
                  ),//want to fixed widget when keyboard will appear
                  ScrollConfiguration(
                      behavior: MyBehavior(),
                      child: SingleChildScrollView(
                         //scrolling widget list
                      )
                  )
                ]
            )
        )
    );

If i set

Align(
          alignment: Alignment.topRight,
          child: Container(
            margin: EdgeInsets.only(top: 60),
            child: (
                Image(
                  image: AssetImage("images/bg_decore_bottom_la.png"),)),
          ),

this code fixed the issue, but for this i need proper top margin

topMargin=totalScreenHeight-ImageWidth;

Upvotes: 2

Views: 3994

Answers (1)

Use a Stack and Positionned widget like so

Stack(
                children: const <Widget>[
                  Positioned(
                    bottom: 0,
                    right:0,
                    child: (Image(
                      image: AssetImage("images/bg_decore_up_la.png"),
                    )),
                  )
                ],
              ),

Upvotes: 3

Related Questions