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
// ... | |
class _RootState extends State<RootWidget> { | |
TenderApiProvider tenderApi = TenderApiProvider(); | |
AppState state = AppState(); | |
Future init() async { | |
return Future.wait(<Future>[ | |
tenderApi.init(), // fetch and store token | |
Future.delayed(const Duration(milliseconds: 2000)) // Let user see the splash for couple of seconds |
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 'service.dart'; | |
class HomeScreen extends StatelessWidget { | |
@override | |
build(BuildContext context) { | |
// When service will notify its listeners, we'll be automatically | |
// rebuilt | |
List<Model> items = Provider.of<Service>(context).items; | |
return Scaffold( |
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
const puppeteer = require('puppeteer'); | |
const alphabet = 'poiuytrewqlkjhgfdsamnbvcxz'.split(''); | |
(async () => { | |
let results = {}; | |
const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']}); | |
const page = await browser.newPage(); | |
await page.setViewport({ width: 1024, height: 768 }); | |
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'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Grid gaps', | |
theme: ThemeData( |
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
// ... | |
var codec = await instantiateImageCodec(byteData); | |
var frameInfo = await codec.getNextFrame(); | |
var img = frameInfo.image; | |
// ... |
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:async'; | |
import 'dart:typed_data'; | |
import 'dart:ui' as ui; | |
import 'package:flutter/material.dart'; | |
void main() async => runApp(MaterialApp(home: Root())); | |
/// Waits till [ui.Image] is generated and renders | |
/// it using [CustomPaint] to render it. Allows use of [MediaQuery] | |
class Root extends StatelessWidget { |
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
/// Very useful package which is part of Flutter. | |
/// Also contains a useful functions, such as [mix] and [smoothStep]. | |
import 'package:vector_math/vector_math.dart'; | |
/// ... | |
/// Main area of interest, this function will | |
/// return color for each particular color on our [ui.Image] | |
int generatePixel(int x, int y, Size size) { | |
/// Compute unified vector, values of its components |
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
// ... | |
/// White dots each 20 pixels | |
if (x % 20 == 0 && y % 20 == 0) { | |
return 0xffffffff; | |
} | |
// ... |
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
/// Takes a unit Vector3 (all values from 0 to 1) | |
/// and returns an int representing color in RGBA format | |
/// Vector3(0, 1, 0) -> 0xff00ff00 | |
int toColorInt(Vector3 vec) { | |
int r = (vec.r * 255).toInt(); | |
int g = (vec.g * 255).toInt(); | |
int b = (vec.b * 255).toInt(); | |
return (b << 0) | (g << 8) | (r << 16) | (255 << 32); | |
} |
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 area of interest, this function will | |
/// return color for each particular color on our [ui.Image] | |
int generatePixel(int x, int y, Size size) { | |
/// Compute unified vector, values of its components | |
/// will be between 0 and 1 | |
var uv = Vector2(x / size.width, y / size.height); | |
/// [Vector2.xxx] is a getter which returns [Vector3] | |
/// with first component of given [Vector2], uv in our case. | |
return toColorInt(uv.xxx); |
OlderNewer