Google maps 如何在Flitter中在谷歌地图上创建一个浮动搜索栏?

Google maps 如何在Flitter中在谷歌地图上创建一个浮动搜索栏?,google-maps,flutter,flutter-layout,Google Maps,Flutter,Flutter Layout,我正试图在我的地图上创建一个浮动搜索栏,就像谷歌地图应用程序中的搜索栏一样。像这样的- 我似乎无法使它漂浮。搜索栏不会覆盖在地图上。它只是在自己的框中渲染 void main() { runApp(MaterialApp( title: 'Navigation Basics', theme: ThemeData.dark(), home: MyAppState(), )); } class M

我正试图在我的地图上创建一个浮动搜索栏,就像谷歌地图应用程序中的搜索栏一样。像这样的-

我似乎无法使它漂浮。搜索栏不会覆盖在地图上。它只是在自己的框中渲染



    void main() {
      runApp(MaterialApp(
        title: 'Navigation Basics',
        theme: ThemeData.dark(),
        home: MyAppState(),
      ));
    }

    class MyAppState extends StatelessWidget {
      final LatLng _center = const LatLng(28.535517, 77.391029);

      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: FloatAppBar(),
            body: Map(_center),
            floatingActionButton: FloatingActionButton(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => Report()),
                );
              },
              child: Icon(Icons.add, semanticLabel: 'Action'),
              backgroundColor: Colors.black87,
            ),
            floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
            bottomNavigationBar: BottomNavBar(),
          ),
        );
      }
    }


    class FloatAppBar extends StatelessWidget with PreferredSizeWidget {
      @override
      Widget build(BuildContext context) {
        return (FloatingSearchBar(
          trailing: CircleAvatar(
            child: Text("RD"),
          ),
          drawer: Drawer(
            child: Container(),
          ),
          onChanged: (String value) {},
          onTap: () {},
          decoration: InputDecoration.collapsed(
            hintText: "Search...",
          ),
          children: [
          ],
        ));
      }

      @override
      Size get preferredSize => Size.fromHeight(kToolbarHeight);
    } 


我希望搜索栏浮动在地图顶部,但它在自己的框中呈现。

我在这里获得了相同的结果:


    void main() {
      runApp(MaterialApp(
        title: 'Navigation Basics',
        theme: ThemeData.dark(),
        home: MyAppState(),
      ));
    }

    class MyAppState extends StatelessWidget {
      final LatLng _center = const LatLng(28.535517, 77.391029);

      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: FloatAppBar(),
            body: Map(_center),
            floatingActionButton: FloatingActionButton(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => Report()),
                );
              },
              child: Icon(Icons.add, semanticLabel: 'Action'),
              backgroundColor: Colors.black87,
            ),
            floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
            bottomNavigationBar: BottomNavBar(),
          ),
        );
      }
    }


    class FloatAppBar extends StatelessWidget with PreferredSizeWidget {
      @override
      Widget build(BuildContext context) {
        return (FloatingSearchBar(
          trailing: CircleAvatar(
            child: Text("RD"),
          ),
          drawer: Drawer(
            child: Container(),
          ),
          onChanged: (String value) {},
          onTap: () {},
          decoration: InputDecoration.collapsed(
            hintText: "Search...",
          ),
          children: [
          ],
        ));
      }

      @override
      Size get preferredSize => Size.fromHeight(kToolbarHeight);
    } 


代码:

堆栈(
儿童:[
//用地图小部件替换此容器
容器(
颜色:颜色,黑色,
),
定位(
前10名,
右:15,
左:15,
子:容器(
颜色:颜色,白色,
孩子:排(
儿童:[
图标按钮(
颜色:颜色。灰色,
图标:图标(图标菜单),
按下:(){},
),
扩大(
孩子:TextField(
光标颜色:颜色。黑色,
键盘类型:TextInputType.text,
textInputAction:textInputAction.go,
装饰:输入装饰(
边框:InputBorder.none,
内容填充:
边缘组。对称(水平:15),
hintText:“搜索…”),
),
),
填充物(
填充:仅限常量边集(右:8.0),
孩子:圆环星(
背景颜色:颜色。深紫色,
子项:文本('RD'),
),
),
],
),
),
),
],
),

更新

我认为这将更适合你现在=>罗迪·达维斯:“)