Skip to content

Instantly share code, notes, and snippets.

View matthew-carroll's full-sized avatar

Matt Carroll matthew-carroll

View GitHub Profile
@matthew-carroll
matthew-carroll / main_repro_text_clipping_bug.dart
Created October 17, 2022 07:33
flutter_text_clipping_bug
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
/// This app reproduces a text painting bug in which some characters, and some
/// descenders are cut off.
///
/// This repro captures an actual state of paragraph style, text style, and canvas
/// scaling. We're painting text in our app based on a document's specification of
/// characters and spacing between them. In general, this is working fine. However
@matthew-carroll
matthew-carroll / dry_layout_stop_gap.dart
Created January 3, 2021 00:39
DryIntrinsicWidth and DryIntrinsicHeight
/// Same as `IntrinsicWidth` except that when this widget is instructed
/// to `computeDryLayout()`, it doesn't invoke that on its child, instead
/// it computes the child's intrinsic width.
///
/// This widget is useful in situations where the `child` does not
/// support dry layout, e.g., `TextField` as of 01/02/2021.
class DryIntrinsicWidth extends SingleChildRenderObjectWidget {
const DryIntrinsicWidth({Key key, Widget child})
: super(key: key, child: child);
@matthew-carroll
matthew-carroll / main.dart
Created July 30, 2020 22:47
Flutter web overflow bug | visual density | working
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@matthew-carroll
matthew-carroll / main.dart
Created July 30, 2020 22:46
Flutter web overflow bug | visual density | repro
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@matthew-carroll
matthew-carroll / main.dart
Created July 30, 2020 22:42
Flutter web overflow bug | multiline text measuring | working
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@matthew-carroll
matthew-carroll / main.dart
Last active July 30, 2020 22:41
Flutter web overflow bug | multiline text measuring | repro
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@matthew-carroll
matthew-carroll / MyView.java
Last active July 6, 2019 11:28
Implements onRestoreInstanceState in a custom View in Android.
@Override
public void onRestoreInstanceState(Parcelable state) {
// Cast the incoming Parcelable to our custom SavedState. We produced
// this Parcelable before, so we know what type it is.
SavedState savedState = (SavedState) state;
// Let our super class process state before we do because we should
// depend on our super class, we shouldn't imply that our super class
// might need to depend on us.
super.onRestoreInstanceState(savedState.getSuperState());
@matthew-carroll
matthew-carroll / MyView.java
Last active July 6, 2019 11:18
Implements onSaveInstanceState in a custom View in Android.
@Override
public Parcelable onSaveInstanceState() {
// Obtain any state that our super class wants to save.
Parcelable superState = super.onSaveInstanceState();
// Wrap our super class's state with our own.
SavedState myState = new SavedState(superState);
myState.name = this.name;
myState.index = this.index;
@matthew-carroll
matthew-carroll / MyView.java
Created July 6, 2019 11:14
Implements Parcelable in a custom View in Android (4/4).
public class MyView extends View {
private static class SavedState extends BaseSavedState {
String name;
int index;
SavedState(Parcelable superState) {
super(superState);
}
private SavedState(Parcel in) {
@matthew-carroll
matthew-carroll / MyView.java
Created July 6, 2019 11:12
Implements Parcelable in a custom View in Android (3/4).
public class MyView extends View {
private static class SavedState extends BaseSavedState {
String name;
int index;
SavedState(Parcelable superState) {
super(superState);
}
private SavedState(Parcel in) {