Notes on working with Hasura & Postgres docker containers in a local mac environment.
Table of content:
| // taken from: https://github.com/iampawan/FlutterBackdrop | |
| // copy paste to https://dartpad.dev/ and should work | |
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(MaterialApp( | |
| debugShowCheckedModeBanner: false, | |
| theme: ThemeData(primarySwatch: Colors.teal), | |
| home: BackdropPage(), |
| // answer for: | |
| // https://stackoverflow.com/questions/64826393/how-can-i-implement-this-specific-scroll-animation-using-flutter/ | |
| import 'package:flutter/material.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( |
Notes on working with Hasura & Postgres docker containers in a local mac environment.
Table of content:
| // Based on Flutter 1.26.0-17.3.pre Dart SDK 2.10.4 | |
| // filed issue at https://github.com/dart-lang/sdk/issues/44876 | |
| main() { | |
| final datetimeParsed = DateTime.parse('2021-02-05T22:37:12.933232+00:00'); | |
| final datetimeMS = DateTime.fromMicrosecondsSinceEpoch(1612564632933232); | |
| print(datetimeParsed.toIso8601String()); // prints 2021-02-05T22:37:12.933Z | |
| print(datetimeMS.toUtc().toIso8601String()); // prints 2021-02-05T22:37:12.933Z | |
| print(datetimeParsed.microsecondsSinceEpoch); // prints 1612564632933000 |
| import 'dart:async'; | |
| import 'package:meta/meta.dart'; | |
| import 'package:hasura_connect/hasura_connect.dart'; | |
| import 'package:http/http.dart' as http; | |
| // problem: | |
| // when subscribing to`HasuraConnect.subscription`, a websocket connection is created on the first subscription | |
| // call. The websocket connection is created only once with the initial subscription and the provided TokenInterceptor | |
| // or headers. When the token expires during an active subscription, HasuraConnect doesn't stop the subscription, or try | |
| // to reconnect with the latest token in in the TokenInterceptor nor does it throw an error. It'll keep calling `onRequest` |
| // so it doesn't conflict with Image from material package | |
| import 'dart:ui' as ui; | |
| import 'package:flutter/material.dart'; | |
| // svg from hero patterns (I Like Food): https://www.heropatterns.com/ | |
| // converted to CustomPainter code using: https://fluttershapemaker.com/ | |
| void main() { | |
| runApp(SvgPatternExample()); |
| // credit: https://stackoverflow.com/a/9195706/10976714 | |
| // The formulas to calculate the coordinates of a point at any given position (from 0 to 1) on the Bezier curve are: | |
| // x(t) = (1-t)^2 * x1 + 2 * (1-t) * t * x2 + t^2 * x3 | |
| // y(t) = (1-t)^2 * y1 + 2 * (1-t) * t * y2 + t^2 * y3 | |
| // where (x1, y1) is the starting point, (x2, y2) is the control point and (x3, y3) is the end point. | |
| // get a point along the Bezier curve line | |
| // If you pass the start, end & control points, along with 0.5 for the halfway position, you get the offset to that point | |
| Offset getQuadraticCurvePoint(Offset start, Offset control, Offset end, double position) { |
| import 'package:flutter/material.dart'; | |
| import 'package:provider/provider.dart'; | |
| void main() { | |
| runApp(const MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| const MyApp({Key? key}) : super(key: key); | |
| @override |
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(const MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| const MyApp({Key? key}) : super(key: key); | |
| @override |
| import 'dart:math'; | |
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(const WindowApp()); | |
| } | |
| class WindowApp extends StatelessWidget { | |
| const WindowApp({Key? key}) : super(key: key); |