如何在应用程序中添加两个 FAB,一个 centerDocked 在底部导航中,另一个在正常位置
How to add two FAB in app one centerDocked in bottom nav and other at normal place
我想在应用中添加两个浮动操作按钮,但不知道如何管理它。示例UI如图所示
也许您可以通过嵌套两个 Scaffold
小部件来实现?
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
title: 'Flutter Demo',
home: Scaffold(
bottomNavigationBar: new BottomAppBar(
shape: CircularNotchedRectangle(),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
onPressed: () {},
icon: Icon(Icons.menu),
),
],
),
),
floatingActionButton: new FloatingActionButton(
child: Icon(Icons.shopping_cart),
onPressed: () {},
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
body: Scaffold(
floatingActionButton: new FloatingActionButton(
child: Icon(Icons.mail),
onPressed: () {},
),
)),
),
);
}
我想在应用中添加两个浮动操作按钮,但不知道如何管理它。示例UI如图所示
也许您可以通过嵌套两个 Scaffold
小部件来实现?
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
title: 'Flutter Demo',
home: Scaffold(
bottomNavigationBar: new BottomAppBar(
shape: CircularNotchedRectangle(),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
onPressed: () {},
icon: Icon(Icons.menu),
),
],
),
),
floatingActionButton: new FloatingActionButton(
child: Icon(Icons.shopping_cart),
onPressed: () {},
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
body: Scaffold(
floatingActionButton: new FloatingActionButton(
child: Icon(Icons.mail),
onPressed: () {},
),
)),
),
);
}