Skip to content

Instantly share code, notes, and snippets.

View samuelematias's full-sized avatar

samuca samuelematias

View GitHub Profile
@escamoteur
escamoteur / get_it_mixin.md
Last active September 21, 2020 22:15
Proposal for a new mixin that allows to connect Objects inside GetIt to connect to the UI

Proposal for the coming get_it mixin for Widgets as I was asked by users to help binding the UI to the objects in GetIt. Highly inspired by @remi_rousselet 's Hooks and provider in this aspect. For people using Hooks I plan a similar GetItHook. Please tell me what you think

  /// all the following functions can be called inside the build function but also
  /// in e.g. in `initState` of a `StatefulWidget`.
  /// The mixin takes care that everything is correctly disposed.

  /// retrieves or creates an instance of a registered type [T] depending on the registration
@rodydavis
rodydavis / dart_enum_description.dart
Created September 6, 2020 18:37
Add Descriptions to Enums in Dart
enum MyEnum {
simple,
special,
complex,
}
extension MyEnumUtils on MyEnum {
String get description {
switch (this) {
case MyEnum.simple:
@lukepighetti
lukepighetti / unused_dependencies.js
Created September 4, 2020 14:26
Search a Flutter project for unused dependencies
/// Finds unused dependencies from pubspec.yaml
///
/// Achieves this by parsing pubspec.yaml and recursively
/// searching the lib folder for an import statement that
/// contains the name of each package. Prints out the results.
const fs = require("fs");
const YAML = require("yaml");
const { execSync } = require("child_process");
/// Read pubspec.yaml
@irvine5k
irvine5k / links.md
Last active August 29, 2020 01:01
TDC SP 2020 TESTES DE WIDGET
@VB10
VB10 / future_extension.dart
Created August 18, 2020 19:30
Future Extension Flutter
extension FutureExtension on Future {
Widget toBuild<T>({Widget Function(T data) onSuccess, Widget onError, dynamic data}) {
return FutureBuilder<T>(
future: this,
initialData: data,
builder: (BuildContext context, AsyncSnapshot snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.waiting:
case ConnectionState.active:
return Center(child: CircularProgressIndicator());
include: all_lint_rules.yaml
analyzer:
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
# This is generated from the i18n vscode extension
- "**/i18n.dart"
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_put_required_named_parameters_first
- always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
- avoid_annotating_with_dynamic
- avoid_as
@barriehadfield
barriehadfield / analysis_options.yaml
Last active August 7, 2020 12:12
Vis.JS interop with Flutter Web (Dart) see https://visjs.org/ for Vis usage
analyzer:
errors:
undefined_prefixed_name: ignore
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main(){
runApp(new MaterialApp(
debugShowCheckedModeBanner: false,
home: new BookSearch(),
));
}
@mutant0113
mutant0113 / FlutterCustomShimmerEffect.dart
Last active November 20, 2020 14:34
FlutterCustomShimmerEffect
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class Shimmer extends StatefulWidget {
Shimmer({
@required this.child,
@required Color baseColor,
@required Color highlightColor,
this.duration = const Duration(milliseconds: 1500),
}) : gradient = LinearGradient(