Created
January 29, 2022 10:01
-
-
Save pietervp/f768f6efab63dc2d2d8b514debbed6c0 to your computer and use it in GitHub Desktop.
flutter/issues/97454
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MainApp()); | |
} | |
class MainApp extends StatelessWidget { | |
const MainApp({Key? key}) : super(key: key); | |
static const String _title = 'Flutter Code Sample'; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: _title, | |
home: _MyMainWidget(), | |
); | |
} | |
} | |
class _MyMainWidget extends StatefulWidget { | |
@override | |
State<StatefulWidget> createState() => _MyMainWidgetState(); | |
} | |
class _MyMainWidgetState extends State<_MyMainWidget> { | |
final double _splitRatio = 1.0 - 0.618; | |
@override | |
Widget build(BuildContext context) { | |
const double splitWidth = 2; | |
return DefaultTextStyle( | |
style: Theme.of(context).textTheme.bodyText2!, | |
child: LayoutBuilder( | |
builder: (BuildContext context, BoxConstraints viewportConstraints) { | |
return SingleChildScrollView( | |
child: ConstrainedBox( | |
constraints: BoxConstraints( | |
minHeight: viewportConstraints.maxHeight, | |
minWidth: viewportConstraints.maxWidth), | |
child: Row( | |
mainAxisSize: MainAxisSize.max, | |
mainAxisAlignment: MainAxisAlignment.start, | |
children: <Widget>[ | |
Container( | |
width: | |
viewportConstraints.maxWidth * _splitRatio - splitWidth, | |
height: viewportConstraints.maxHeight, | |
alignment: Alignment.topLeft, | |
), | |
Container( | |
width: splitWidth, | |
color: Colors.amber, | |
constraints: BoxConstraints( | |
minHeight: viewportConstraints.maxHeight, | |
minWidth: splitWidth)), | |
Container( | |
constraints: BoxConstraints( | |
minHeight: viewportConstraints.maxHeight, | |
minWidth: | |
viewportConstraints.maxWidth * (1.0 - _splitRatio)), | |
color: Colors.purple, | |
alignment: Alignment.topLeft, | |
child: CustomPaint( | |
painter: TextLayoutEnginePainter(), | |
isComplex: true, | |
willChange: true, | |
), | |
), | |
], | |
), | |
), | |
); | |
}, | |
), | |
); | |
} | |
// Build left Panel widget, containing JSON/XML/Plain text editor and Frame properties configuration | |
} | |
class TextLayoutEnginePainter extends CustomPainter { | |
TextLayoutEnginePainter(); | |
@override | |
void paint(Canvas canvas, Size size) { | |
canvas.save(); | |
canvas.translate(0, 0); | |
canvas.translate(0, 0); | |
canvas.translate(0, 0); | |
canvas.translate(0, 0); | |
canvas.translate(0, 0); | |
canvas.translate(0, 8.736328125); | |
canvas.translate(0, 8.736328125); | |
canvas.scale(0.005859375, -0.005859375); | |
canvas.translate(0, 0); | |
canvas.scale(1, 1); | |
final pathLetterE = Path(); | |
pathLetterE.moveTo(862, 342); | |
pathLetterE.lineTo(1048, 319); | |
pathLetterE.cubicTo(1019, 211, 964, 125, 885, 66); | |
pathLetterE.cubicTo(806, 7, 704, -24, 581, -24); | |
pathLetterE.cubicTo(426, -24, 302, 25, 211, 120); | |
pathLetterE.cubicTo(121, 214, 75, 350, 75, 522); | |
pathLetterE.cubicTo(75, 700, 122, 840, 213, 938); | |
pathLetterE.cubicTo(304, 1036, 425, 1086, 571, 1086); | |
pathLetterE.cubicTo(712, 1086, 830, 1037, 919, 941); | |
pathLetterE.cubicTo(1008, 845, 1054, 708, 1054, 533); | |
pathLetterE.cubicTo(1054, 523, 1053, 506, 1053, 485); | |
pathLetterE.lineTo(261, 485); | |
pathLetterE.cubicTo(267, 369, 301, 278, 360, 217); | |
pathLetterE.cubicTo(419, 156, 494, 124, 582, 124); | |
pathLetterE.cubicTo(647, 124, 705, 142, 751, 176); | |
pathLetterE.cubicTo(797, 210, 835, 267, 862, 342); | |
pathLetterE.close(); | |
pathLetterE.moveTo(271, 633); | |
pathLetterE.lineTo(864, 633); | |
pathLetterE.cubicTo(857, 722, 833, 790, 796, 834); | |
pathLetterE.cubicTo(739, 903, 664, 938, 573, 938); | |
pathLetterE.cubicTo(491, 938, 420, 910, 364, 855); | |
pathLetterE.cubicTo(309, 800, 276, 725, 271, 633); | |
pathLetterE.close(); | |
canvas.translate(4099, 0); | |
canvas.translate(-4099, -0); | |
canvas.scale(1, 1); | |
canvas.translate(0, 0); | |
canvas.scale(170.66666666666666, -170.66666666666666); | |
canvas.translate(0, -8.736328125); | |
canvas.translate(0, -8.736328125); | |
canvas.translate(0, 0); | |
canvas.translate(0, 0); | |
canvas.translate(0, 8.736328125); | |
canvas.translate(0, 8.736328125); | |
canvas.scale(0.005859375, -0.005859375); | |
canvas.translate(0, 0); | |
canvas.scale(1, 1); | |
canvas.translate(0, 0); | |
canvas.translate(-0, -0); | |
canvas.translate(1366, 0); | |
canvas.translate(-1366, -0); | |
for(var i = 0; i < 100; i ++){ | |
canvas.translate(i*1100, 0); | |
canvas.drawPath( | |
pathLetterE, | |
Paint() | |
..style = PaintingStyle.fill | |
..color = Colors.black); | |
canvas.translate(-i*1100, -0); | |
} | |
canvas.translate(2960, 0); | |
canvas.translate(-2960, -0); | |
canvas.translate(4099, 0); | |
canvas.translate(-4099, -0); | |
canvas.translate(5123, 0); | |
canvas.translate(-5123, -0); | |
canvas.scale(1, 1); | |
canvas.translate(0, 0); | |
canvas.scale(170.66666666666666, -170.66666666666666); | |
canvas.translate(0, -8.736328125); | |
canvas.translate(0, -8.736328125); | |
canvas.translate(0, 0); | |
canvas.restore(); | |
} | |
@override | |
bool shouldRepaint(covariant CustomPainter oldDelegate) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment