Skip to content

Instantly share code, notes, and snippets.

View tomasbaran's full-sized avatar
📱
developing a mobile app

Tomas Baran tomasbaran

📱
developing a mobile app
View GitHub Profile
@tomasbaran
tomasbaran / main.dart
Last active April 3, 2024 22:17
isPalindrome
bool isPalindrome(int number) {
// Core logic explained on an example 1234
// 1234 == 4321
// old new
// Default values
// 1234 0
// Loop starts:
// 123 4 (0*10 +4)
// 12 43 (4*10+3)
// 1 432 (43*10 +2)
WEB CONFIG
flavor.dart:
```
import 'package:flutter/foundation.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:today/models/enums.dart';
@tomasbaran
tomasbaran / main.dart
Last active June 29, 2023 02:35
new-test
class RomanNumbers {
int romanCharToInt(String romanChar) {
switch (romanChar) {
case 'I':
return 1;
case 'V':
return 5;
case 'X':
return 10;
case 'L':
@tomasbaran
tomasbaran / main.dart
Created June 28, 2023 22:20
Amco challenge: romanToDecimalNumber
class RomanNumbers {
static int romanToDecimal(String romanNumber) {
Map<String, int> romanMap = {
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
'M': 1000,
@tomasbaran
tomasbaran / ANSI escape codes
Last active October 19, 2023 21:49
Colorize Debug Console Logs
Reset: \x1B[0m
Cursive: \x1B[3m // new data from db
Black: \x1B[30m
Red: \x1B[31m // errors
Green: \x1B[32m // manager/controller
Yellow: \x1B[33m // db data
Blue: \x1B[34m // flutter
Magenta: \x1B[35m
Cyan: \x1B[36m
White: \x1B[37m // local helper functions
@tomasbaran
tomasbaran / audio_file.dart
Created December 4, 2021 11:45
audio background not looping
import 'package:ambee2/models/animations/light_animation.dart';
import 'package:audio_service/audio_service.dart';
import 'package:flutter/material.dart';
// import 'package:just_audio/just_audio.dart';
import 'package:audioplayers/audioplayers.dart';
// Two lines below: this is how I call the audio to start
// await lightAnimation.audioHandler.setRepeatMode(AudioServiceRepeatMode.all);
// await lightAnimation.audioHandler.playUrl(lightAnimation.audioUrl, volumeSetValue);
@tomasbaran
tomasbaran / send_feedback.dart
Last active July 29, 2023 20:48
[Flutter template] Send Feedback Button
import 'package:flutter/material.dart';
import 'package:today/globals/constants.dart';
import 'package:today/services/auth_service.dart';
import 'package:today/style/style_constants.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'dart:io';
import 'package:flutter_email_sender/flutter_email_sender.dart';
import 'package:package_info_plus/package_info_plus.dart';
@tomasbaran
tomasbaran / fetch_list_of_jsons_api.dart
Last active May 13, 2020 10:29
[Flutter template] Fetch list of jsons api into your Flutter project.
// Call the method e.g. from initState like this: FetchListOfJsonsApi().getDecodedBody();
//
// Install the http plugin here: https://pub.dev/packages/http
import 'package:http/http.dart' as http;
import 'dart:convert';
class FetchListOfJsonsApi {
final String url;
FetchListOfJsonsApi({
@tomasbaran
tomasbaran / fetch_json_api.dart
Last active May 13, 2020 10:29
[Flutter template] Fetch json api into your Flutter project.
// Call the method e.g. from initState like this: FetchListOfJsonsApi().getDecodedBody();
//
// Install the http plugin here: https://pub.dev/packages/http
import 'package:http/http.dart' as http;
import 'dart:convert';
class FetchListOfJsonsApi {
final String url;
FetchListOfJsonsApi({
@tomasbaran
tomasbaran / main.dart
Last active June 22, 2023 11:38
[Flutter template] Save JSON file locally on your phone in Flutter
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'dart:convert';
const String kFileName = 'myJsonFile.json';
const InputDecoration kInputDecoration = InputDecoration(
border: OutlineInputBorder(),
labelText: 'Label Text',
);