Skip to content

Instantly share code, notes, and snippets.

View tayormi's full-sized avatar
🥰
Working Silently

Temitope Ajiboye tayormi

🥰
Working Silently
View GitHub Profile
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
@tayormi
tayormi / codemagic.yaml
Created November 20, 2019 15:09
CodeMagic configuration for ReciMix
workflows:
default-workflow:
name: Default Workflow
environment:
flutter: stable
scripts:
- |
# set up debug key.properties
keytool -genkeypair \
-alias androiddebugkey \
@tayormi
tayormi / home.dart
Last active November 26, 2019 13:07
Main.dart for ReciMix
import 'package:flutter/material.dart';
import 'package:recimix/pages/widgets/customAppBar.dart';
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: CustomAppBar(),
body: SingleChildScrollView(
child: Column(
@tayormi
tayormi / customAppBar.dart
Last active November 26, 2019 13:31
CustomAppBar for ReciMix
import 'package:flutter/material.dart';
class CustomAppBar extends StatelessWidget {
final List<BottomNavigationBarItem> bottomBarItems = [];
final bottomNavigationBarItemStyle = TextStyle(fontStyle: FontStyle.normal, color: Colors.black);
CustomAppBar() {
bottomBarItems.add(
BottomNavigationBarItem(
icon: Icon(Icons.home, color: Color(0xFF78AA39),),
title: Text("Home", style: bottomNavigationBarItemStyle,)
static String validateCardNum(String input) {
if (input.isEmpty) {
return Strings.fieldReq;
}
input = getCleanedNumber(input);
if (input.length < 8) {
return Strings.numberIsInvalid;
}
@tayormi
tayormi / jwt_parser.dart
Created July 2, 2020 17:07
Parse JWT Tokens in Dart
import 'dart:convert';
Map<String, dynamic> parseJwtPayLoad(String token) {
final parts = token.split('.');
if (parts.length != 3) {
throw Exception('invalid token');
}
final payload = _decodeBase64(parts[1]);
final payloadMap = json.decode(payload);
@tayormi
tayormi / list.extension.dart
Created November 3, 2020 21:30
A helper function to immutably add to lists
// A simple helper function to allow us to immutably add to lists.
extension ImmutableList<T> on List<T> {
List<T> concat(T item) => List<T>.from(<T>[...this, item]);
}
extension StringExtension on String {
String get svg => 'assets/images/svg/$this.svg';
String get png => 'assets/images/png/$this.png';
}
// Then you can do this
SvgPicture.asset(
'back'.svg,
height: 16,
width: 16,
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
part 'request_state_notifier.freezed.dart';
abstract class RequestStateNotifier<T> extends StateNotifier<RequestState<T>> {
RequestStateNotifier() : super(RequestState.idle());
//It returns a Future with state if you want to avoid ProviderListener
Future<RequestState<T>> makeRequest(Future<T> Function() function) async {
import 'package:quiver/async.dart';
CountdownTimer _countdownTimer;
Listener(
behavior: HitTestBehavior.translucent,
onPointerMove: (_) {
_countdownTimer =
CountdownTimer(Duration(minutes: 5), Duration(seconds: 1));
},