Skip to content

Instantly share code, notes, and snippets.

class Adaptation<T> {
const Adaptation();
Type get type => T;
T adapt(ThemeData theme, T defaultValue) => defaultValue;
}
class ThemeData {
factory ThemeData({ Iterable<Adaptation>? adaptations }) {
return ThemeData.raw(
adaptationMap: <Type, Adaptation>{
import 'package:flutter/material.dart';
/// Animated text widget that will animate changes in [temperature] to match
/// the effect on the new thermostats.
class AnimatedTemperatureText extends StatefulWidget {
final int temperature;
final Color textColor;
const AnimatedTemperatureText({
super.key,
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class Item extends StatelessWidget {
const Item({ super.key, required this.title, required this.color });
// From the original Flutter gallery demo
// dev/integration_tests/flutter_gallery/lib/demo/material/page_selector_demo.dart
import 'package:flutter/material.dart';
class _PageSelector extends StatelessWidget {
const _PageSelector({ this.icons });
final List<Icon>? icons;
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
class MenuDemo extends StatelessWidget {
static const slug = 'menu';
Widget menuItem(IconData? icon, int itemNumber) {
return PopupMenuItem<Object>(
child: Row(
children: [
// A CoordinatedSliver that auto-scrolls to align itself with the
// top of the viewport when a scroll gesture leaves it partially visible.
//
// This demo must be run in a simulator or on a mobile device
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
class Item extends StatelessWidget {
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class Destination {
const Destination(this.index, this.title, this.icon, this.color);
final int index;
final String title;
final IconData icon;
final MaterialColor color;
}
// ReszingHeaderSliver AppBar Parts example: contacts version with autoscroll
// New coordinator API; coordinated slivers report layout info directly.
// https://gist.github.com/HansMuller/fd7b154108a142a0ea2ef1be24d09e94
// dartpad.dev/?id=fd7b154108a142a0ea2ef1be24d09e94
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
// Settings app bar demo with auto-scroll and new coordinator API.
// This demo must be run in a simulator or on a mobile device
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
// ReszingHeaderSliver AppBar Parts example: contacts version with autoscroll
// New coordinator API; coordinated slivers report layout info directly.
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';