child_view.dart 1.13 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/rendering.dart';

import 'framework.dart';
8
import 'media_query.dart';
9 10 11

export 'package:flutter/rendering.dart' show ChildViewConnection;

12
class ChildView extends StatelessWidget {
13 14 15 16
  ChildView({ Key key, this.child }) : super(key: key);

  final ChildViewConnection child;

17
  @override
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  Widget build(BuildContext context) {
    return new _ChildViewWidget(
      child: child,
      scale: MediaQuery.of(context).devicePixelRatio
    );
  }
}

class _ChildViewWidget extends LeafRenderObjectWidget {
  _ChildViewWidget({
    ChildViewConnection child,
    this.scale
  }) : child = child, super(key: new GlobalObjectKey(child));

  final ChildViewConnection child;
  final double scale;

35
  @override
36
  RenderChildView createRenderObject(BuildContext context) => new RenderChildView(child: child, scale: scale);
37

38
  @override
39
  void updateRenderObject(BuildContext context, RenderChildView renderObject) {
40 41 42 43 44
    renderObject
      ..child = child
      ..scale = scale;
  }
}