Skip to content

Instantly share code, notes, and snippets.

View natintosh's full-sized avatar
🚀

Ogunye Nathaniel Oluwatobiloba natintosh

🚀
View GitHub Profile
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'dart:math' as math;
class CustomLayout extends MultiChildRenderObjectWidget {
CustomLayout({
Key key,
List<Widget> children = const <Widget>[],
}) : super(key: key, children: children);
Context context = view.getContext();
ContentResolver cr = context.getContentResolver();
ContentValues values;
try {
// create a file for test
File file = new File(context.getFilesDir(), "1234568");
file.createNewFile();
try (OutputStream os = new FileOutputStream(file)) {
os.write("test".getBytes());
@natintosh
natintosh / ffont.py
Created March 11, 2023 16:23
Custom fonts CookBook example not working as expected flutter/website#3591 Based on what @jason-simmons mentioned, I created the following python script to "fix" your custom font files to use the correct weights that flutter respects. Create a src directory and put all your fonts in there. Create an empty out directory and the script will place …
import os
from fontTools import ttLib
# Declare your font file names and the correct weights here
to_change = {
'Galano Grotesque Thin.otf': 100,
'Galano Grotesque Thin Italic.otf': 100,
'Galano Grotesque Extra Light.otf': 200,
'Galano Grotesque Extra Light Italic.otf': 200,
'Galano Grotesque Light.otf': 300,
@natintosh
natintosh / Common-Currency.json
Last active July 9, 2020 09:23 — forked from ksafranski/Common-Currency.json
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
import 'package:flutter_driver/driver_extension.dart';
import 'package:intlphonenumberinputtest/main.dart' as app;
main() {
enableFlutterDriverExtension();
app.main();
}
void main() {
print(resistorColor('Red'));
}
const List<String> colors = [
'Black',
'Brown',
'Red',
'Orange',
'Yellow',
void main() {
print(resistorColor('Red'));
}
const List<String> colors = [
'Black',
'Brown',
'Red',
'Orange',
'Yellow',
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@natintosh
natintosh / phone_format_as_you_type.dart
Created December 16, 2019 09:09
A class formats phone number input as you type
typedef OnInputFormatted<T> = void Function(T value);
class PhoneFormatter extends TextInputFormatter {
final RegExp separatorChars = RegExp(r'[^\d]+');
final RegExp allowedChars = RegExp(r'[\d+]');
final String isoCode;
final String dialCode;
final OnInputFormatted<TextEditingValue> onInputFormatted;
import 'package:flutter/services.dart';
import 'package:string_mask/string_mask.dart';
class PhoneMaskInputFormatter extends TextInputFormatter {
final String mask;
final String escapeChar;
final RegExp regExp = RegExp(r'[^\d]+');
Map<int, String> _separatorMap;