简体   繁体   English

扑两个孩子:<Widget> 在同一个 Stack() 内

[英]Flutter two children: <Widget> inside same Stack()

How can I fuse two children <widget> inside the same Stack() > For example, fuse this ...如何在同一个Stack()融合两个孩子<widget> > 例如,融合这个......

Stack(
   children: <Widget>[
    GoogleMap(
      initialCameraPosition:
      CameraPosition(target: LatLng(currentLocation.latitude,
          currentLocation.longitude), zoom: 17),
      onMapCreated: _onMapCreated,
      myLocationEnabled: true,
      mapType: _currentMapType,
      markers: Set<Marker>.of(markers.values),

    ),
    Padding(

with this:有了这个:

    Stack(
      children: <Widget>[
        // Replace this container with your Map widget
        Container(
          color: Colors.black,
        ),
        Positioned(

What about the ... operator which flattens a list into a list.将列表扁平化为列表的...运算符呢... Eg:例如:

  List<Widget> getFirstStackChildren() {
    return [
      Text("first stack first child"),
      Text("first stack second child")
    ];
  }

  List<Widget> getSecondStackChildren() {
    return [
      Text("second stack first child"),
      Text("second stack second child")
    ];
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
          children: <Widget>[
            ...getFirstStackChildren(),
            ...getSecondStackChildren(),
          ],
        )
    );
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM