Skip to content

Instantly share code, notes, and snippets.

@creativecreatorormaybenot
creativecreatorormaybenot / main.dart
Created July 15, 2020 14:54
prefer_adjacent_string_concatenation
void main() {
const a1 = '';
// Correct prefer_adjacent_string_concatenation lint.
print(a1 + '');
const a2 = Custom();
// Incorrect prefer_adjacent_string_concatenation lint.
@creativecreatorormaybenot
creativecreatorormaybenot / main.dart
Last active July 9, 2020 06:11
error: An expression whose value can be 'null' must be null-checked before it can be dereferenced - line 9
class Foo {
const Foo({required this.bar});
final void Function()? bar;
void doSomething() {
if (bar != null) {
// Analyzer still complains that bar can be null.
bar();
}
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Perception is Everything',
home: MyHomePage(),
final path = Path()
..moveTo(0, 0)
..lineTo(-w / 2, 0)
..lineTo(-w / 2, sh)
// And a bunch more operations..
;
canvas.drawShadow(path, _shadowColor, _radius / 64, false);
canvas.drawPath(path, paint);
// In RenderCompositedClock (parent layout)
location.layout(constraints, parentUsesSize: true);
// In RenderLocation
_textPainter = TextPainter(...);
_textPainter.layout(maxWidth: constraints.biggest.width); // constraints here are what was given in location.layout
size = _textPainter.size; // size here is the size of the RenderLocation render object
// Back in RenderCompositedClock after laying out the location
locationData.offset = Offset( // Setting the offset positions the child
@override
double transformInternal(double t) {
return troughTransform(elasticTransform(t));
}
double elasticTransform(double t) {
final b = 12 / 27;
return 1 + pow(2, -10 * t) * sin(((t - b / 4) * pi * 2) / b);
}
final path = Path()
..moveTo(mf * (1 - l1), -hd)
..lineTo(2 * mf, -hd)
..quadraticBezierTo(
2.6 * mf,
-hd,
2.6 * mf,
-hd * 3,
)
..cubicTo(
void paintIcon(PaintingContext context, Offset offset) {
final canvas = context.canvas;
canvas.save();
canvas.translate(0, radius * -indentationFactor / 2);
drawCondition(canvas);
canvas.restore();
}
@override
void attach(PipelineOwner owner) {
super.attach(owner);
animation.addListener(markNeedsPaint);
}
/// Declares that a [RenderWeatherIcon] is a repaint boundary.
///
/// This makes sure that other weather icons and the background
/// do not have to repaint when only this icon changes.
@override
bool get isRepaintBoundary => true;