Skip to content

Instantly share code, notes, and snippets.

@InMatrix
InMatrix / adaptive_alert.dart
Last active April 1, 2023 00:16
Adaptive AlertDialog Demo
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'dart:io' show Platform;
void main() => runApp(const AdaptiveDialogDemo());
class AdaptiveDialogDemo extends StatelessWidget {
const AdaptiveDialogDemo({super.key});
@override
@InMatrix
InMatrix / main.dart
Last active May 12, 2023 01:08
adaptive-text-field
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
// Change the value of `isIOS` to adapt the look of text fields
// `isIOS` is a stand-in for `Platform.isIOS` on mobile,
const isIOS = true;
void main() {
runApp(MyApp());
}
@InMatrix
InMatrix / main.dart
Last active March 10, 2023 22:20
CupertinoAlertDialog with Material Colors
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(const AlertDialogApp());
class AlertDialogApp extends StatelessWidget {
const AlertDialogApp({super.key});
@override
Widget build(BuildContext context) {
@InMatrix
InMatrix / main.dart
Created March 10, 2023 22:05
enchanted-osmium-6980
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(const AlertDialogApp());
class AlertDialogApp extends StatelessWidget {
const AlertDialogApp({super.key});
@override
@InMatrix
InMatrix / main.dart
Last active March 3, 2023 01:09
adaptive-segmented-button
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
void main() {
runApp(const SegmentedButtonApp());
}
class SegmentedButtonApp extends StatelessWidget {
const SegmentedButtonApp({super.key});
@InMatrix
InMatrix / main.dart
Last active June 26, 2020 00:30
An example of using the characters package https://pub.dev/packages/characters
// Prerequisite: add the characters package as a dependency in your pubspec.yaml.
import 'package:characters/characters.dart';
void main(List<String> arguments) {
print(textOverflowEllipsis('😸cats', 10));
print(textOverflowEllipsis('🦏rhinoceroses', 10));
}
// This function converts text overflow to an ellipsis
// when the text's length exceeds the given character limit.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@InMatrix
InMatrix / main.dart
Created April 15, 2020 04:29
Demo of CustomMultiChildLayout
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@InMatrix
InMatrix / main.dart
Created February 10, 2020 17:57
Split a string by the star emoji
void main() {
print(splitStarSeparatedWords('space⭐is⭐for⭐everybody'));
}
List splitStarSeparatedWords(String text) {
return text.split('⭐');
}
════════ Exception Caught By rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performResize():
Vertical viewport was given unbounded height.
Viewports expand in the scrolling direction to fill their container.In this case, a vertical viewport was given an unlimited amount of vertical space in which to expand. This situation typically happens when a scrollable widget is nested inside another scrollable widget.
If this widget is always nested in a scrollable widget there is no need to use a viewport because there will always be enough vertical space for the children. In this case, consider using a Column instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size the height of the viewport to the sum of the heights of its children.
When the exception was thrown, this was the stack:
#0 RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1147:15)
#1 RenderVi