Skip to content

Instantly share code, notes, and snippets.

@ffkev
ffkev / main.dart
Created April 21, 2025 05:09
Gist to display a base64 encoded image in Flutter
import 'dart:convert';
import 'dart:typed_data';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@ffkev
ffkev / index.html
Created February 26, 2025 11:14
Disable automatic page_view tracking in GA4
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('set', { 'send_page_view': false });
</script>
@ffkev
ffkev / update_json_bool.dart
Created September 5, 2024 11:42
Code that will modify the isSelected value in JSON based on what values are passed to the parser function
import 'dart:convert';
void main() {
String jsonString = '''
{
"baseRequest": [
{"iconCode": 58513, "chipLabel": "India", "isDisabled": true, "isSelected": false},
{"iconCode": 58513, "chipLabel": "Africa", "isDisabled": true, "isSelected": false},
{"iconCode": 58395, "chipLabel": "America", "isDisabled": false, "isSelected": true},
@ffkev
ffkev / launch_web_same_tab.dart
Created August 27, 2024 06:20
Launch a website in the same tab in Flutter web
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@ffkev
ffkev / hyper_link_text_widget.dart
Created August 20, 2024 20:04
This is sample flutter code for a Text widget which will exhibit hyperlink capabilities such as showing a blue underline in the text when it is hovered on top of
@ffkev
ffkev / main.dart
Created July 30, 2024 18:58
Code to enable focusable widgets across a Flutter Web app
void main() async {
WidgetsFlutterBinding.ensureInitialized();
GoRouter.optionURLReflectsImperativeAPIs = true;
usePathUrlStrategy();
await FlutterFlowTheme.initialize();
runApp(
FocusTraversalGroup(
policy: WidgetOrderTraversalPolicy(),
@ffkev
ffkev / main.dart
Created July 23, 2024 07:50
To save and open a PDF file that is received in a base64 format
// ignore_for_file: use_build_context_synchronously
import 'dart:convert';
import 'dart:io';
import 'package:advance_pdf_viewer2/advance_pdf_viewer.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pdf_viewer_project/pages/pdf_viewer_page.dart';
@ffkev
ffkev / icons.dart
Created July 12, 2024 03:54
This dart file contains all the codepoint values that you would need to access all material icons
This file has been truncated, but you can view the full file.
// BEGIN GENERATED ICONS
/// <i class="material-icons md-36">10k</i> &#x2014; material icon named "10k".
static const IconData ten_k = IconData(0xe000, fontFamily: 'MaterialIcons');
/// <i class="material-icons-sharp md-36">10k</i> &#x2014; material icon named "10k" (sharp).
static const IconData ten_k_sharp = IconData(0xe700, fontFamily: 'MaterialIcons');
/// <i class="material-icons-round md-36">10k</i> &#x2014; material icon named "10k" (round).
static const IconData ten_k_rounded = IconData(0xf4df, fontFamily: 'MaterialIcons');
@ffkev
ffkev / niv_encryption_decryption.dart
Created May 20, 2024 03:30
AES gmc Encryption / Decryption logic in Flutter
import 'dart:convert';
import 'dart:typed_data';
import 'package:encrypt/encrypt.dart' as encrypt;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(EncryptionApp());
}
@ffkev
ffkev / main.dart
Last active April 11, 2024 06:00
There is a MediaQuery property in Flutter which you can use to restrict scaling of your fonts on different devices based on the device accessibility settings.
MediaQuery(
// This will set scaling for the app to always remain 1:1 globally
data: MediaQuery.of(context).copyWith(textScaler: TextScaler.linear(1.0)),
// Wrap your Material App with MediaQuery to implement this
child: MaterialApp.router(
title: 'ScaleFactorText',
...
),
);