Skip to content

Instantly share code, notes, and snippets.

import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(MyApp());
const sampleText = '''
Flutter is an open-source UI software development kit created by Google.
It is used to develop applications for Android, iOS, Linux, Mac, Windows, Google Fuchsia,[4] and the web from a single codebase.[5]
@aorcsik
aorcsik / string-truncate.swift
Last active September 27, 2017 16:22
A little truncate function extension for the default String type
extension String {
/// Truncates the string to length number of characters and
/// appends optional trailing string if longer
func truncate(length: Int, trailing: String? = nil) -> String {
if countElements(self) > length {
return self.substringToIndex(advance(self.startIndex, length)) + (trailing ?? "")
} else {
return self
}
}
@luizventurote
luizventurote / truncate-string-words.php
Last active April 8, 2016 08:49
Truncate a string provided by the maximum limit without breaking a word.
<?php
/**
* truncate a string provided by the maximum limit without breaking a word
* @param string $str
* @param integer $maxlen
* @return string
*/
function truncateStringWords($str, $maxlen) {
if (strlen($str) <= $maxlen) return $str;