This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/painting.dart'; | |
/// Utility class for generation list of gradient colors. | |
class ColorGradient { | |
ColorGradient._(); | |
/// Generates the list from `length` colors which starts from | |
/// `startColor` and ends with `endColor`. | |
/// | |
/// The length must be greater than 0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
const subject = 'I have a dog. I have a cat. I have a bird.'; | |
final result = replaceStringByOccurrence(subject, 'have', '*have no*', 0); | |
print(result); | |
} | |
/// Looks for `occurrence` of `search` in `subject` and replace it with `replace`. | |
/// | |
/// The occurrence index is started from 0. | |
String replaceStringByOccurrence( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 = Success | |
1 = Operation not permitted | |
2 = No such file or directory | |
3 = No such process | |
4 = Interrupted system call | |
5 = Input/output error | |
6 = No such device or address | |
7 = Argument list too long | |
8 = Exec format error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<Uint8List> _downloadImage() async { | |
String dir = (await getApplicationDocumentsDirectory()).path; | |
File file = new File('$dir/$_filename'); | |
if (file.existsSync()) { | |
var image = await file.readAsBytes(); | |
return image; | |
} else { | |
var response = await http.get(_url,); | |
var bytes = response.bodyBytes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:typed_data'; | |
import 'dart:ui'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$count = 60; | |
$re = "/(?:((?>.{1,${count}}(?:(?<=[^\S\r\n])[^\S\r\n]?|(?=\r?\n)|$|[^\S\r\n]))|.{1,${count}})(?:\r?\n)?|(?:\r?\n|$))/"; | |
$string = 'This function will always return an array even the if the text is not processed i.e. for already short text. The above code returns the unprocessed short text by adding it into array.'; | |
echo trim(preg_replace($re, "$1\r\n", $string)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'dart:math'; | |
void main() { | |
/// | |
/// Launch the application | |
/// | |
runApp(Application()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Main video widget. | |
class VideoState extends State { | |
Widget build(...) { | |
return Row( | |
childred: [ | |
SideBar(), // can be hidden (depending on this overlay which can be created deeper should change its sze as VideoMonitor widget will also be resized. | |
VideoMonitor(), // contains VideoMonitorGrid | |
], | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:typed_data'; | |
import 'dart:io'; | |
import 'package:http/http.dart'; | |
import 'package:path_provider/path_provider.dart'; | |
downloadFile(String url, {String filename}) async { | |
var httpClient = http.Client(); | |
var request = new http.Request('GET', Uri.parse(url)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/gestures.dart' show DragStartBehavior; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/widgets.dart'; | |
void main() { | |
runApp( | |
MaterialApp( | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primaryColor: Colors.indigo, |
OlderNewer