问题描述
我正在尝试重新配置 BottomAppBar 类。问题是,我无法弄清楚 CircularNotchedRectangle 类如何获得 FAB 矩形位置的可见性以计算缺口。
CircularNotchedRectangle 源是 here
为了给出一个工作示例,我从 here 中获取了 _DemoBottomAppBar 的源代码,删除了所有按钮和内容,您在下面看到的是结果。如您所见,就我所见,FAB 位置和 FAB 构造都没有传递到 BottomAppBar() 或 CircularNotchedRectangle() 中。
重申一下,我的问题是,当没有明确传递任何内容时,_DemoBottomAppBar 类中的唯一一个 CircularNotchedRectangle() 实例如何获取有关树上方 _BottomAppBarDemoState 小部件中 FAB 的信息?
有人可以帮忙吗?真的很感激……
import 'package:Flutter/material.dart';
void main() {
runApp(const BottomAppBarDemo());
}
class BottomAppBarDemo extends StatefulWidget {
const BottomAppBarDemo({Key? key}) : super(key: key);
@override
State createState() => _BottomAppBarDemoState();
}
class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,title: const Text('Bottom App Bar Demo'),),floatingActionButton: FloatingActionButton(
onpressed: () {},child: const Icon(Icons.add),tooltip: 'Create',floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,bottomNavigationBar: _DemoBottomAppBar(
),);
}
}
class _DemoBottomAppBar extends StatelessWidget {
const _DemoBottomAppBar();
@override
Widget build(BuildContext context) {
return BottomAppBar(
shape: CircularNotchedRectangle(),color: Colors.blue,child: IconTheme(
data: IconThemeData(color: Theme.of(context).colorScheme.onPrimary),child: Row(
children: <Widget>[
IconButton(
tooltip: 'Open navigation menu',icon: const Icon(Icons.menu),onpressed: () {},],);
}
编辑...
好的,所以我想我会发布更新,因为我想我可能已经解决了。如果我是对的,那么答案很简单。
本质上,我们将 CircularNotchedRectangle() 类传递给 BottomAppBar 构造函数,以便可以在绑定到 BottomAppBar 类的某个方法中访问 CircularNotchedRectangle.getouterPath()。这就是 CircularNotchedRectangle 可以访问未专门传递给其构造函数的变量的方式。
希望这对任何可能感兴趣的人有所帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)