如何在 Appbar 上制作一些具有不同对齐方式的图标?

Rom*_*ine 17 android-appbarlayout flutter flutter-appbar

我遇到了一些问题。我想制作一个图像、一个文本和两个图标,AppBar但我不能让它按我想要的方式工作。

我试图在图像和文本之后连续制作一些字体。图像和文本成功显示在 my 中AppBar,但其余 2 种字体(手推车和通知)显示一些错误。

Widget build(BuildContext context) {
    return new Scaffold(
      backgroundColor: Colors.amber,  
      appBar: new AppBar
        (
        title: new Row
          (
          mainAxisAlignment: MainAxisAlignment.start,
            children:
            [
              Image.asset('images/logoapp.png',fit: BoxFit.contain,height: 32,), 
              Container(padding: const EdgeInsets.all(8.0), child: Text('Solid Shop'))
            ],
          )

        ),
Run Code Online (Sandbox Code Playgroud)

....

Tir*_*tel 35

用于leading在 appBar 标题之前设置一个小部件,并actions用于指定 appBar 中出现在 appBar 标题右侧的小部件列表。

AppBar(
    leading: Image.asset('yourImage'), // you can put Icon as well, it accepts any widget.
    title: Text ("Your Title"),
    actions: [
        Icon(Icons.add),
        Icon(Icons.add),
    ],
);
Run Code Online (Sandbox Code Playgroud)

在此处阅读更多相关信息


Cop*_*oad 10

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text("Solid Shop"),
      leading: Image.asset("your_image_asset"),
      actions: <Widget>[
        IconButton(icon: Icon(Icons.shopping_cart), onPressed: () {}),
        IconButton(icon: Icon(Icons.message), onPressed: () {}),
      ],
    ),
  );
}
Run Code Online (Sandbox Code Playgroud)