颤抖如何携带前端小部件

时间:2018-10-09 08:35:41

标签: google-maps dart flutter

无论如何,我们可以将小部件放在屏幕的前面,而让其他小部件放在屏幕的后面吗?,尝试过Stack小部件但没有用,我正在使用抖动google_maps_flutter实现Google Maps库,请参见下面的代码:

import 'dart:ui' as ui;
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter/material.dart';

final size = MediaQueryData.fromWindow(ui.window).size;
final GoogleMapOverlayController controller =
    GoogleMapOverlayController.fromSize(
  width: size.width,
  height: size.height,
);

class GoogleMapView extends StatefulWidget {
  _GoogleMapViewState createState() => _GoogleMapViewState();
}

class _GoogleMapViewState extends State<GoogleMapView> {
  final mapController = controller.mapController;
  final Widget mapWidget = GoogleMapOverlay(controller: controller);

  @override
  void initState() {
    super.initState();
    GoogleMapController.init();
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Container(
        alignment: Alignment.center,
        height: size.height,
        width: size.width,
        child: new Stack(
          children: <Widget>[
            mapWidget,
            new Container(
              height: 100.0,
              alignment: Alignment.topCenter,
              child: new Text('Hey there!'),
            )
          ],
        ),
      ),
      navigatorObservers: <NavigatorObserver>[controller.overlayController],
    );
  }
}

请参阅screenshot,该Join Query in Apache Ignite的Google地图顶部应该与屏幕的右上角对齐。如何使用Flutter Stack小部件来实现此功能,自昨天开始我就遇到了问题,并且找不到任何解决方案,有人可以帮助我吗?谢谢!

1 个答案:

答案 0 :(得分:0)

Stack可以很好地实现此目的,只是Google Maps插件正在呈现本机视图,而其他视图无法覆盖本机视图。

您可能想关注https://github.com/flutter/flutter/issues/73

尤其要查看此评论https://github.com/flutter/flutter/issues/73#issuecomment-417040742