mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
109 lines
3.4 KiB
Dart
109 lines
3.4 KiB
Dart
// Copyright 2014 The Flutter 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/material.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
|
|
import '../rendering/src/solid_color_box.dart';
|
|
|
|
// Solid color, RenderObject version
|
|
void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int flex = 0 }) {
|
|
final RenderSolidColorBox child = RenderSolidColorBox(backgroundColor);
|
|
parent.add(child);
|
|
final FlexParentData childParentData = child.parentData;
|
|
childParentData.flex = flex;
|
|
}
|
|
|
|
// Solid color, Widget version
|
|
class Rectangle extends StatelessWidget {
|
|
const Rectangle(this.color, { Key key }) : super(key: key);
|
|
|
|
final Color color;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Expanded(
|
|
child: Container(
|
|
color: color,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
double value;
|
|
RenderObjectToWidgetElement<RenderBox> element;
|
|
BuildOwner owner = BuildOwner();
|
|
void attachWidgetTreeToRenderTree(RenderProxyBox container) {
|
|
element = RenderObjectToWidgetAdapter<RenderBox>(
|
|
container: container,
|
|
child: Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: Container(
|
|
height: 300.0,
|
|
child: Column(
|
|
children: <Widget>[
|
|
const Rectangle(Color(0xFF00FFFF)),
|
|
Material(
|
|
child: Container(
|
|
padding: const EdgeInsets.all(10.0),
|
|
margin: const EdgeInsets.all(10.0),
|
|
child: Row(
|
|
children: <Widget>[
|
|
RaisedButton(
|
|
child: Row(
|
|
children: <Widget>[
|
|
Image.network('https://flutter.dev/images/favicon.png'),
|
|
const Text('PRESS ME'),
|
|
],
|
|
),
|
|
onPressed: () {
|
|
value = value == null ? 0.1 : (value + 0.1) % 1.0;
|
|
attachWidgetTreeToRenderTree(container);
|
|
},
|
|
),
|
|
CircularProgressIndicator(value: value),
|
|
],
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
),
|
|
),
|
|
),
|
|
const Rectangle(Color(0xFFFFFF00)),
|
|
],
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
),
|
|
),
|
|
),
|
|
).attachToRenderTree(owner, element);
|
|
}
|
|
|
|
Duration timeBase;
|
|
RenderTransform transformBox;
|
|
|
|
void rotate(Duration timeStamp) {
|
|
timeBase ??= timeStamp;
|
|
final double delta = (timeStamp - timeBase).inMicroseconds.toDouble() / Duration.microsecondsPerSecond; // radians
|
|
|
|
transformBox.setIdentity();
|
|
transformBox.rotateZ(delta);
|
|
|
|
owner.buildScope(element);
|
|
}
|
|
|
|
void main() {
|
|
final WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized();
|
|
final RenderProxyBox proxy = RenderProxyBox();
|
|
attachWidgetTreeToRenderTree(proxy);
|
|
|
|
final RenderFlex flexRoot = RenderFlex(direction: Axis.vertical);
|
|
addFlexChildSolidColor(flexRoot, const Color(0xFFFF00FF), flex: 1);
|
|
flexRoot.add(proxy);
|
|
addFlexChildSolidColor(flexRoot, const Color(0xFF0000FF), flex: 1);
|
|
|
|
transformBox = RenderTransform(child: flexRoot, transform: Matrix4.identity(), alignment: Alignment.center);
|
|
final RenderPadding root = RenderPadding(padding: const EdgeInsets.all(80.0), child: transformBox);
|
|
|
|
binding.renderView.child = root;
|
|
binding.addPersistentFrameCallback(rotate);
|
|
}
|