Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get size widget renderbox

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

typedef void OnWidgetSizeChange(Size size);

class MeasureSizeRenderObject extends RenderProxyBox {
  Size oldSize;
  final OnWidgetSizeChange onChange;

  MeasureSizeRenderObject(this.onChange);

  @override
  void performLayout() {
    super.performLayout();

    Size newSize = child.size;
    if (oldSize == newSize) return;

    oldSize = newSize;
    WidgetsBinding.instance.addPostFrameCallback((_) {
      onChange(newSize);
    });
  }
}

class MeasureSize extends SingleChildRenderObjectWidget {
  final OnWidgetSizeChange onChange;

  const MeasureSize({
    Key key,
    @required this.onChange,
    @required Widget child,
  }) : super(key: key, child: child);

  @override
  RenderObject createRenderObject(BuildContext context) {
    return MeasureSizeRenderObject(onChange);
  }
}
Comment

get size widget renderbox

var myChildSize = Size.zero;

Widget build(BuildContext context) {
  return ...( 
    child: MeasureSize(
      onChange: (size) {
        setState(() {
          myChildSize = size;
        });
      },
      child: ...
    ),
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: check if object is empty js 
Javascript :: convert javascript function to typescript online 
Javascript :: fb like image window js 
Javascript :: node blank string 
Javascript :: java script loop array 
Javascript :: can i use promise.all conditional in vue js 
Javascript :: isnumber javascript 
Javascript :: nodejs app.on connection 
Javascript :: argument and parameter 
Javascript :: data error in jquery validate add custom element 
Javascript :: Angular : pass data to component loaded via route 
Javascript :: buffer to base 64 online 
Javascript :: how to prevent random method from giving more than two same numbers js site:stackoverflow.com 
Javascript :: Total shopping amount from an object in javascript 
Javascript :: javascript create new array with default values by one line 
Javascript :: jquery image onerror not working 
Javascript :: react date component with word month 
Javascript :: Serve JSON on a Specific Route 
Javascript :: Falsy Bouncer 
Javascript :: FTP Get a directory listing of the current 
Javascript :: check if value in mapping is empty struct in solidity ethereum 
Javascript :: variable local and global 
Javascript :: useLinkClickHandler 
Javascript :: template.json exlude files from generating 
Javascript :: javascript random number between 10 and 100 
Javascript :: check if device is in dark mode js 
Javascript :: js react change slide by touch event 
Javascript :: minutes to seconds javascript 
Javascript :: javascript get element by class domlist undefined 
Javascript :: javascript date set day of week 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =