Как наметить верхнюю и левую ведущую иконку - PullRequest
0 голосов
/ 16 апреля 2020

У меня проблемы с полями left и top на панели приложений, я использую значок leading, но мне не удалось изменить его положение.

Ниже приведен мой код:

child: Scaffold(
            appBar: PreferredSize(
              preferredSize: Size.fromHeight(150.0),
              child: AppBar(
                leading: SizedBox(
                  width: 200,
                height: 200,

                child: Transform.scale(scale: 2,
                    child: IconButton(
                      icon: Image.asset('assets/app_logo.png')
                  ,
                ),
                )
                ),
            centerTitle: true,
            actions: <Widget>[
              IconButton(
                  icon: Image.asset('assets/path.png'))
            ],
            bottom: TabBar(
                labelColor: Colors.white,
                indicatorColor: Colors.lime,

                tabs:[
                  Tab(icon: null,text: 'RECENT',),
                  Tab(icon: null, text: 'TOPICS',),
                  Tab(icon: null, text: 'AUTHORS',),
                ]
            ),
          )

Здесь мой стиль для значка leading:

leading: SizedBox(
                      width: 200,
                    height: 200,

                    child: Transform.scale(scale: 2,
                        child: IconButton(
                          icon: Image.asset('assets/app_logo.png')
                      ,
                    )

Это снимок экрана:

enter image description here

1 Ответ

1 голос
/ 17 апреля 2020

Я не думаю, что вы можете легко изменить размер ведущего виджета относительно макета панели приложений

Но вы можете использовать виджет Stack, чтобы поставить свой lo go на панели приложений, например:

@override
Widget build(BuildContext context) {
  return MaterialApp(
    home: Scaffold(
      appBar: PreferredSize(
        preferredSize: Size.fromHeight(150.0),
        child: Stack(
          children: <Widget>[
            AppBar(
              bottom: TabBar(
                controller: _tabController,
                labelColor: Colors.white,
                indicatorColor: Colors.lime,
                tabs: [
                  Tab(
                    icon: null,
                    text: 'RECENT',
                  ),
                  Tab(
                    icon: null,
                    text: 'TOPICS',
                  ),
                  Tab(
                    icon: null,
                    text: 'AUTHORS',
                  ),
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.only(left: 20, top: 60),
              child: Container(
                width: 50,
                height: 50,
                color: Colors.yellow,
                child: Center(child: Text('Logo')),
              ),
            ),
          ],
        ),
      ),
    ),
  );
}

enter image description here

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