Skip to content

Instantly share code, notes, and snippets.

View talamaska's full-sized avatar

Zlati Pehlivanov talamaska

View GitHub Profile
import 'package:flutter/material.dart';
void main() async {
runApp(const DynamicHeader());
}
class DynamicHeader extends StatelessWidget {
const DynamicHeader({Key? key}) : super(key: key);
@override
@talamaska
talamaska / counter_button.dart
Created August 31, 2021 10:36 — forked from xsahil03x/counter_button.dart
Simple counter button
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rxdart/rxdart.dart';
typedef CounterEdit = Future<bool> Function(int);
/// Returns true if the [valueBeforeZero] is handled by user.
typedef OnValueZero = Future<bool> Function(int valueBeforeZero);
@talamaska
talamaska / wait_for_ex.dart
Created August 19, 2021 08:12
The aim of waitForEx is to repair the stack trace the users sees the 'expected' stack trace rather than the microtask stack trace.
T waitForEx<T>(Future<T> future) {
Exception exception;
T value;
try {
value = cli.waitFor<T>(future);
}
// ignore: avoid_catching_errors
on AsyncError catch (e) {
if (e.error is Exception) {
exception = e.error as Exception;
@talamaska
talamaska / bottom_sheet_fix.dart
Created August 2, 2021 19:47 — forked from crimsonsuv/bottom_sheet_fix.dart
Flutter Modal bottom sheet whith input fix and full screen sheet
//Flutter Modal Bottom Sheet
//Modified by Suvadeep Das
//Based on https://gist.github.com/andrelsmoraes/9e4af0133bff8960c1feeb0ead7fd749
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
const Duration _kBottomSheetDuration = const Duration(milliseconds: 200);
@talamaska
talamaska / bottom_sheet_fix_status_bar.dart
Created August 2, 2021 19:47
Flutter Modal bottom sheet that supports full screen height
//Flutter Modal Bottom Sheet
//Modified by Giorgio Bertolotti
//Based on https://gist.github.com/crimsonsuv/b25d5ebd04236f9be2aa66accba19446
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
const Duration _kBottomSheetDuration = const Duration(milliseconds: 200);
@talamaska
talamaska / bottom_sheet.dart
Created August 2, 2021 19:46 — forked from andrelsmoraes/bottom_sheet.dart
Modal Bottom Sheet with Input Fields fix for Flutter (Fix issue with overlap with keyboard and fix for tapping to dismiss) - Flutter Version: Channel beta, v0.5.1
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
@talamaska
talamaska / bottom_sheet.dart
Created August 2, 2021 18:26 — forked from slightfoot/bottom_sheet.dart
Modal Bottom Sheet with Input Fields fix for Flutter (Fix issue with overlap with keyboard and fix for tapping to dismiss)
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
@talamaska
talamaska / adaptive_scaffold.dart
Created July 7, 2021 20:28 — forked from rodydavis/adaptive_scaffold.dart
Flutter Adaptive Scaffold
import 'package:flutter/material.dart';
const kTabletBreakpoint = 720.0;
const kDesktopBreakpoint = 1200.0;
const kSideMenuWidth = 250.0;
class AdaptiveScaffold extends StatelessWidget {
final List<TabItem> tabs;
final int selectedIndex;
final ValueChanged<int> onSelectionChanged;
@talamaska
talamaska / dart_inheritance.dart
Created April 26, 2021 20:18
Function arguments are contravariant (whereas generics are covariant)
/// quick question about Something<T extends SomethingElse>
class Bar {}
class Baz extends Bar {}
typedef Foo<T extends Bar> = void Function(T);
void printBaz(Baz baz) => print(baz);
final list = <Foo>[];
@talamaska
talamaska / dart.yml
Created March 12, 2021 12:09 — forked from lukepighetti/dart.yml
Flutter Web + GitHub Actions + Firebase Hosting Preview Channels
# .github/workflows/dart.yml
name: build
on:
push:
branches: [master]
pull_request:
branches: [master]