Как кнопка с плавающим действием размещается по отношению к высоте и ширине экрана во флаттере - PullRequest
0 голосов
/ 02 августа 2020

Как получить положение кнопки с плавающим действием с помощью медиа-запроса.

1 Ответ

0 голосов
/ 03 августа 2020

Контейнер в виджете floatinACtionButton

api радио экрана: MediaQuery

Например

// floatinButton слева

 floatingActionButton: Container(
    width: MediaQuery.of(context).size.width ,
    height: MediaQuery.of(context).size.height / 8,
    color: Colors.red,
    child: Row(
      children: <Widget>[
        FloatingActionButton(
          onPressed: _incrementCounter,
          tooltip: 'Increment',
          child: Icon(Icons.add , size: 30,),
        ),
        Expanded(child: Container())
      ],
    ),

  ),
  floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);

enter image description here

// center floatingButton

 floatingActionButton: Container(
        width: MediaQuery.of(context).size.width ,
        height: MediaQuery.of(context).size.height / 8,
        color: Colors.red,
        child: Row(
          children: [
            Expanded(child: Container()),
            FloatingActionButton(
              onPressed: _incrementCounter,
              tooltip: 'Increment',
              child: Icon(Icons.add , size: 30,),
            ),
            Expanded(child: Container())
          ],
        ),

      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
    );

введите описание изображения здесь

...