Skip to content

Instantly share code, notes, and snippets.

View MarcinusX's full-sized avatar
🇵🇱
 🇵🇱

Marcin Szałek MarcinusX

🇵🇱
 🇵🇱
View GitHub Profile
@MarcinusX
MarcinusX / timesamp_to_local_datetimes_linter.dart
Last active March 6, 2023 09:48
A linter for parsing protobuf's Timestamps to DateTime. The goal is to always include isLocal: true when doing it.
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/source/source_range.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
class PreferTimestampsToLocalDateTimes extends DartLintRule {
PreferTimestampsToLocalDateTimes() : super(code: _code);
@MarcinusX
MarcinusX / riverpod_future_provider_test.dart
Created January 3, 2023 14:17
This gist is to represent unexpected behaviour when testing FutureProvider in Riverpod 2.1.3
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
void main() {
group('RiverpodFutureProviders', () {
// this fails - async is returned
testWidgets('Future.value works', (tester) async {
@MarcinusX
MarcinusX / main.dart
Created March 8, 2021 07:29
Broken RTL on Web example
import 'package:flutter/material.dart';
void main() => runApp(RtlBrokenApp());
class RtlBrokenApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Padding(
/// Copied from https://github.com/flutter/flutter/issues/33988#issuecomment-600748507
/// Steps to reproduce:
/// 1. Move the map location, bool value keeps changing.
/// 2. Tap on the container anywhere.
/// 3. Now again move the map.
/// 4. bool value does not change.(onCameraIdle() not working).
/// Occurs on google_maps_flutter:0.5.27
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/material.dart';
class AirHockey extends StatefulWidget {
@override
_AirHockeyState createState() => _AirHockeyState();
}
@MarcinusX
MarcinusX / main.dart
Created March 21, 2019 19:36
Ripple effect transition
import 'package:flutter/material.dart';
import 'package:rect_getter/rect_getter.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Fab overlay transition',
https://marcinszalek.pl/tag/bmi-calculator/
@MarcinusX
MarcinusX / card_title.dart
Last active September 4, 2018 07:06
BMI Calculator - Weight
import 'package:flutter/material.dart';
const TextStyle _titleStyle = TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w500,
color: Color.fromRGBO(14, 24, 35, 1.0),
);
const TextStyle _subtitleStyle = TextStyle(
fontSize: 8.0,
public async setValidation(source: Excel.Range, target: Excel.Range) {
Excel.run(function (context) {
return context.sync().then(() => {
target.dataValidation.rule = {
list: {
inCellDropDown: true,
source: source.values.toString(),
}
};
return context.sync();
@MarcinusX
MarcinusX / officeCustomProperties.md
Created July 13, 2018 12:56
Explanation on sharing custom properties between Office 2013 and Office Online

Office VSTO + jsAPI custom properties manual

Explanation

So far in VSTO we were saving properties separately in every Worksheet. JavaScript API for Office doesn't have such function (as of 13/07/2018). Instead we can save those properties in Workbook's documentProperties which are accessable both in VSTO and JS.

Note: CP means CustomProperties (too long to write every time)

JS (actually TS):

Loading

There is a bug with loading CP, so in order to load them we have to ensure that the list is not empty: