Skip to content

Instantly share code, notes, and snippets.

@VictorUvarov
VictorUvarov / dart.json
Created December 22, 2020 23:19
vscode user snippets
"Generate a freezed union": {
"prefix": "funion",
"description": "Generate a freezed union",
"body": [
"import 'package:freezed_annotation/freezed_annotation.dart';",
"",
"part '$TM_FILENAME_BASE.freezed.dart';",
"",
"@freezed",
"abstract class $1 with _$$1 {",
@VictorUvarov
VictorUvarov / scale_bounce_gesture.dart
Created October 23, 2020 02:50
Container that scales a widget like it is being push down
import 'package:flutter/widgets.dart';
class ScaleBounceGesture extends StatefulWidget {
final Widget child;
final VoidCallback onPressed;
final Duration duration;
ScaleBounceGesture({
Key key,
@required this.child,
@VictorUvarov
VictorUvarov / delete-other-branches.sh
Created September 12, 2020 05:10
Remove all your local git branches but keep master
git branch | grep -v "master" | xargs git branch -D
git reset $(git commit-tree HEAD^{tree} -m "A new start")
class TimestampSerializerPlugin implements SerializerPlugin {
@override
Object beforeSerialize(Object object, FullType specifiedType) {
if (object is DateTime && specifiedType.root == DateTime) {
return object.toUtc();
}
return object;
}
@override
import 'package:flutter/widgets.dart';
class FadeBetween extends StatelessWidget {
/// Whether the first child is shown
final bool condition;
final Widget first;
final Widget second;
final Duration duration;
const FadeBetween({
@VictorUvarov
VictorUvarov / video_player.dart
Created October 25, 2019 14:15
Chew video player widget and view model
import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
class VideoPlayer extends StatelessWidget {
final String url;
final String filePath;
final String assetPath;
final bool showControls;
const VideoPlayer({
class Service {
List<int> _list = [];
final _controller = StreamController<int>();
Stream<List<int>> get myStream$ => _controller.stream;
void addItem(int item){
_list.add(item);
_controller.add(_list);
}
}
@VictorUvarov
VictorUvarov / select_card.dart
Last active September 9, 2019 21:23
a card to group radial buttons and their descriptions
import 'package:flutter/material.dart';
import 'package:grouped_buttons/grouped_buttons.dart';
class SelectCard extends StatelessWidget {
final FormFieldValidator<String> validator;
final void Function(String) onSelect;
final List<String> options;
final String selected;
const SelectCard({
@VictorUvarov
VictorUvarov / http_service.dart
Created August 25, 2019 17:30
Upload form data with http package
import 'package:http/http.dart' as http;
var request = new http.MultipartRequest("POST", url);
request.fields['user'] = '[email protected]';
request.files.add(http.MultipartFile.fromPath(
'package',
'build/package.tar.gz',
contentType: new MediaType('application', 'x-tar'),
));
request.send().then((response) {