0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

メモ: Flutter WIdget のサイズをリアルタイムに得る方法(仮)

Last updated at Posted at 2020-08-22

Flutter for Web で、画面サイズを変えた時によう(仮)
任意のDOM を Widget 上に上書きしたい時とか


class MyContainer extends SingleChildRenderObjectWidget {
  MyContainer({Key key,Widget child}):super(key:key, child:child);

  double lastDx = 0.0;
  double lastDy = 0.0;
  double lastDw = 0.0;
  double lastDh = 0.0;

  @override
  RenderObject createRenderObject(BuildContext context) {
    return MyContainerRenderObject(this);
  }
}

class MyContainerRenderObject extends RenderProxyBox {
  MyContainer myparent;

  MyContainerRenderObject(this.myparent) {

  }

  @override
  void paint(PaintingContext context, Offset offset) {
    assert(!debugNeedsLayout);
    this.myparent.lastDx = offset.dx;
    this.myparent.lastDy = offset.dy;
    this.myparent.lastDw = size.width;
    this.myparent.lastDh = size.height;
    print("size: ${this.size}");
    print("offset ${offset.dx} ${offset.dy}");
    super.paint(context, offset);
  }
}

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?