Skip to content

Instantly share code, notes, and snippets.

@alexd1971
alexd1971 / hybrid_test.dart
Created October 16, 2017 16:42
Hybrid test example
import 'package:test/test.dart';
import 'package:stream_channel/stream_channel.dart';
main() {
StreamChannel ch;
setUpAll(() async {
ch = spawnHybridUri('server_start.dart', stayAlive: true);
String message = await ch.stream.first;
print(message);
});
@alexd1971
alexd1971 / my_component.dart
Last active November 9, 2017 20:54
AngularDart Google ReCaptcha component. Advanced usage example
import 'dart:async';
import 'package:angular/angular.dart';
import 'package:angular_forms/angular_forms.dart';
import 'package:angular_grecaptcha/angular_grecaptcha.dart';
import 'package:http/browser_client.dart';
@Component(
selector: 'my-component',
templateUrl: 'my_component.html',
styleUrls: const [
@alexd1971
alexd1971 / my_test.dart
Created November 4, 2017 21:53
Unexplained async behaviour
@TestOn('browser');
import 'package:test/test.dart';
import 'package:http/browser_client.dart';
import 'package:http_exception/http_status.dart';
main() {
final http = new BrowserClient();
test('Http request', () async {
int start = new DateTime.now().millisecondsSinceEpoch;
final response = await http.get('http://localhost');
@alexd1971
alexd1971 / api.dart
Created November 24, 2017 09:03
Dart file upload
import 'dart:async';
import 'dart:io';
import 'package:mime/mime.dart';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf_rest/shelf_rest.dart';
class Api {
@Post('upload')
Future upload(shelf.Request request) async {
@alexd1971
alexd1971 / MimeTypes.dart
Created November 27, 2017 06:25
MimeTypes
class MimeTypes {
static const String jpeg = 'image/jpeg',
static const String png = 'image/png',
static const String gif = 'image/gif',
static const String txt = 'text/plain',
static const String doc = 'application/msword',
static const String docx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
static const String xls = 'application/vnd.ms-excel',
static const String xlsx = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
static const String ppt = 'application/vnd.ms-powerpoint',
@alexd1971
alexd1971 / index.html
Created December 13, 2017 12:11
Webdriver tests failing with dartdevc
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script async type="application/dart" src="main.dart"></script>
<script async type="text/javascript" src="packages/browser/dart.js"></script>
<title>Hello Dart</title>
</head>
class UserId {
String _id;
UserId(this._id);
@override
bool operator == (other) {
return _id == other._id;
}
int get hashCode => _id.hashCode;
}
@alexd1971
alexd1971 / main.dart
Created May 21, 2018 05:47
Socks5 communication in dart
import 'dart:async';
import 'dart:io';
/// Фазы установки соединения с socks5-сервером
enum Socks5 {init, auth, connect}
Future main() async {
String targetHost = 'delidela.com';
int targetPort = 443;
@alexd1971
alexd1971 / main.dart
Created June 14, 2018 13:11
Flutter TabView problem example
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
@alexd1971
alexd1971 / app_component.dart
Last active July 25, 2018 19:54
Angular Dart Material Datepicker theming is not working
import 'package:angular/angular.dart';
import 'package:angular_components/utils/browser/window/module.dart';
import 'package:angular_components/material_datepicker/module.dart';
import 'package:angular_components/material_datepicker/material_date_time_picker.dart';
@Component(
selector: 'my-app',
styleUrls: ['app_component.css'],
templateUrl: 'app_component.html',