-2

I'm trying to align the asset to the top right side of the screen, I also tried positioned widgets. but that didn't help. and I'm also kinda new at flutter. so is there any other widget to achieve this?

here is the code i tried

Column(
          children: [
            Image.asset(
              'assets/design_el_1.png',
              alignment: Alignment.topRight
            ),
           
               other elements
               other elements
               other elements
            ]
          );

enter image description here

I want to align the lite purple element on the top, how can I align the image to the top right of the screen?

4 Answers 4

2
Column(
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    Image.asset(
                        'assets/images/onboard.jpeg',
                        width: 200,
                        height: 100,
                    ),
                  ],
                ),
               ],
            )

Output:

enter image description here

1

you have to use Align Widget like the code given below

Align(
    alignment: Alignment.topRight,
      child: Image.asset("Assets/user.png"))
0
1

Wrap your Image.asset with Align widget and use it's alignment: Alignment.centerRight property. Your image will surely align right side.

 Align(
        alignment: Alignment.centerRight,
          child: Image.asset("Assets/user.png"))

P.S :- You may use your asset image instead of my image :)

Output

0
1

Just wrap the widget with Align

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Column(
      children: [
        Align(
          alignment: Alignment.topRight,
          child: Image.asset("images/demo.png"),
        ),
        Image.asset("images/demo.png"),
        Image.asset("images/demo.png"),
      ],
    ));
  }
}

Picture

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.