Как переместить позицию контейнера? - PullRequest
0 голосов
/ 13 апреля 2020

Я хочу, чтобы у моего контейнера была немного оставленная позиция. Я пытался использовать отступы, но это не сработает. Ниже мой код Контейнер (цвет: Colors.blue,

    //padding: EdgeInsets.all(10),
    child: Row(

      children: <Widget>[

        Padding(
          child: new Text(
              'BIKE DETAILS',
              style: new TextStyle(
                  fontWeight: FontWeight.bold, fontSize: 20.0),
              textAlign: TextAlign.left,

            ),
          padding: EdgeInsets.only(bottom: 20.0),),
          SizedBox(width: 20),


    ),
  ),
    ],

Я хочу, чтобы синий контейнер переместился немного влево.

1 Ответ

0 голосов
/ 13 апреля 2020

Приведенный ниже код сместит синий контейнер влево. Если вы хотите переместить текст вправо, оберните текст с помощью виджета Padding, как вы делали ранее. или оберните текст в container, а затем используйте EdgeInsets, чтобы задать c заполнение по своему усмотрению.

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('text'),
      ),
      body: Container(
        color: Colors.blue,
        height: 50, //change to your desired height.
        width:
            MediaQuery.of(context).size.width, //change to your desired width.
        /// Below in the margin parameter EdgeInsets.fromLTRB will help you give specific
        /// margins from Left, Top, Right and Bottom respectively.
        margin: EdgeInsets.fromLTRB(5, 20, 5, 20),
        child: Row(
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(10.0),
              child: Text(
                'BIKE DETAILS',
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
                textAlign: TextAlign.left,
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(10.0),
              child: Text(
                'BIKE DETAILS',
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
                textAlign: TextAlign.left,
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Output of the Code

Надеюсь, это поможет !!!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...