'Flutter relative top and right of positioned in stack

I am creating drag images on left side of the screen, while there is model on right side of the screen. The images can be dragged onto the model in 2 areas, and should remain there relative to model. The top and right are placed so those to areas are on correct position. What I'm trying to achieve is to scale top and right parameters of Positioned widget, but after trying a lot of things, i have failed. As far as i see, the Stack scales the first element but the rest same the same. The code is here:

Stack(
        children: [
          Image.asset(
            "assets/draggable/model.png",
            width: 335 *
                (MediaQuery.of(context).size.height -
                    MediaQuery.of(context).padding.top) /
                1010,
          ),
          Positioned(
            top: 385 *
                ((MediaQuery.of(context).size.height -
                        MediaQuery.of(context).padding.top) /
                    1010),
            right: 66 *
                (MediaQuery.of(context).size.height -
                    MediaQuery.of(context).padding.top) /
                1010,
            child: DragTarget<String>(
                builder: (
                  BuildContext context,
                  List<dynamic> accepted,
                  List<dynamic> rejected,
                ) {
                  return Image.asset(
                    myImage2,
                    width: 205 *
                      (MediaQuery.of(context).size.height -
                          MediaQuery.of(context).padding.top) /
                      1010,
                  );
                },
                onAccept: (String data) {
                  setState(() {
                    if (data.split("/")[2].contains("d")) {
                      myImage2 = data;
                    }
                  });
                },
              ),
          ),
          Positioned(
            top: 185 *
                ((MediaQuery.of(context).size.height -
                        MediaQuery.of(context).padding.top) /
                    1010),
            right: 60 *
                (MediaQuery.of(context).size.height -
                    MediaQuery.of(context).padding.top) /
                1010,
            child: DragTarget<String>(
              builder: (
                BuildContext context,
                List<dynamic> accepted,
                List<dynamic> rejected,
              ) {
                return Image.asset(
                  myImage,
                  width: 216 *
                      (MediaQuery.of(context).size.height -
                          MediaQuery.of(context).padding.top) /
                      1010,
                );
              },
              onAccept: (String data) {
                setState(() {
                  if (data.split("/")[2].contains("c")) {
                    myImage = data;
                  }
                });
              },
            ),
          ),
        ],
      ),

PS: scaling this way works perfectly for width and right but the top parameter is bad. Also the 1010 and is height of screen i measured the width,top and right with, so I'm scaling it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source