Skip to content

Instantly share code, notes, and snippets.

View bienvenuelisis's full-sized avatar
🎯
Focusing

Kokou AGBAVON bienvenuelisis

🎯
Focusing
View GitHub Profile
@SashaKryzh
SashaKryzh / flutter_extension_methods.dart
Last active June 14, 2024 19:49
List of my favorite extension methods in Flutter.
import 'package:flutter/material.dart';
extension BuildContextExtensions on BuildContext {
ThemeData get theme => Theme.of(this);
TextTheme get textTheme => theme.textTheme;
ColorScheme get colorScheme => theme.colorScheme;
DefaultTextStyle get defaultTextStyle => DefaultTextStyle.of(this);
@Frankdroid7
Frankdroid7 / make_file_name.dart
Created August 16, 2022 19:09
A simple function to check through a folder in the device if a file name already exists. If it does, append "(1)" to it to make it unique.
// This function helps to add a string at the back of each file name IF that
// file already exists in the user's file system, so that each file name will
// be unique.
Future<String> makeFileName(String path, String fileName) async {
bool fileExists = await File('$path/$fileName').exists();
if (fileExists) {
int counter = 1;
List newFileExt = fileName.split('.');
String ext = newFileExt[1]; // refers to the file extension.