简体   繁体   中英

How to make relative layout in flutter app

Please see this image - https://ibb.co/YpjJsLZ

In above image how can I place burger image to center of white view. I tried using Align & Center widget but its no fitting properly.

How can relative layout works in flutter?

Flutter does not have layout types like android,

But you can place burger image using stack widget.

You can follow this tutorial for reference.

you can not use Relative Layout in Flutter but it Replace using "Stack".

The stack is a widget in Flutter that contains a list of widgets and positions them on top of the other.

stack allows developers to overlap multiple widgets into a single screen and renders them from bottom to top.

Hence, the first widget is the bottommost item, and the last widget is the topmost item.

import 'package:flutter/material.dart';

class StackWidget extends StatefulWidget {
  @override
  _StackWidgetState createState() => _StackWidgetState();
}

class _StackWidgetState extends State<StackWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      color: Colors.yellow,
      height: 300,
      child: Stack(
        alignment: Alignment.topLeft,
        children: [
          Container(
            color: Colors.cyan,
            width: 200,
            height: 200,
          ),
          Container(
            color: Colors.red,
            width: 150,
            height: 150,
          ),
          Container(
            color: Colors.blue,
            width: 100,
            height: 100,
          ),
        ],
      ),
    );
  }
}

Output:

在此处输入图像描述

Done☻♥.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM