Skip to content

Instantly share code, notes, and snippets.

View bizz84's full-sized avatar

Andrea Bizzotto bizz84

View GitHub Profile
@bizz84
bizz84 / update-android-project.sh
Created November 18, 2024 09:17
Script to update Gradle, Java and other Android project settings in a Flutter project
#!/bin/bash
# Update Gradle, Java and other Android project settings in a Flutter project
# See: https://gradle.org/releases/
DESIRED_GRADLE_VERSION="8.9"
# Build errors often show the required Java version
DESIRED_JAVA_VERSION="17"
# See: https://developer.android.com/ndk/downloads
DESIRED_NDK_VERSION="27.0.12077973"
# The minimum Android SDK version
@bizz84
bizz84 / app_name_remote_config.json
Created October 7, 2024 13:38
Remote config template JSON for a Flutter app
{
"config" : {
"required_version": "2.0.0"
}
}
@bizz84
bizz84 / flutter_ship_remote_config.json
Last active October 7, 2024 11:40
Remote config for the Flutter Ship app (prod flavor)
{
"config" : {
"required_version": "0.3.0"
}
}
@bizz84
bizz84 / flutter_ship_remote_config.json
Last active October 7, 2024 11:40
Remote config for the Flutter Ship app (stg flavor)
{
"config" : {
"required_version": "0.3.0"
}
}
@bizz84
bizz84 / flutter_ship_remote_config.json
Last active October 7, 2024 11:44
Remote config for the Flutter Ship app (dev flavor)
{
"config" : {
"required_version": "0.4.0"
}
}
@bizz84
bizz84 / triple_tap_detector.dart
Last active September 9, 2024 11:14
Custom TripleTapDetector widget using RawGestureDetector
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class TripleTapDetector extends StatelessWidget {
const TripleTapDetector({
super.key,
required this.child,
required this.onTripleTap,
});
final Widget child;
@bizz84
bizz84 / future_ignore_wtf.dart
Created August 2, 2024 09:06
Example showing that Future.ignore() doesn't work as expected
import 'dart:async';
import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
FlutterError.onError = (details) {
log('FlutterError error: ${details.exception}');
FlutterError.presentError(details);
@bizz84
bizz84 / go_router_basic.dart
Created June 23, 2024 20:07
Simple GoRouter navigation to a details page
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
final _router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (context, state) => const HomeScreen(),
routes: [
GoRoute(
@bizz84
bizz84 / flutter_bootstrap.js
Created May 21, 2024 08:40
Custom Flutter Web App Initialization Logic with CSS Loader
{{flutter_js}}
{{flutter_build_config}}
// Manipulate the DOM to add a loading spinner will be rendered with this HTML:
// <div class="loading">
// <div class="loader" />
// </div>
const loadingDiv = document.createElement('div');
loadingDiv.className = "loading";
document.body.appendChild(loadingDiv);
@bizz84
bizz84 / logger_interceptor.dart
Created May 13, 2024 07:38
Simple logger interceptor for Dio without extra dependencies
import 'dart:developer';
import 'package:dio/dio.dart';
/// A simple interceptor used to log all network requests
/// For more details, see: https://github.com/bizz84/flutter-tips-and-tricks/blob/main/tips/0152-log-status-code-emoji/index.md
class LoggerInterceptor implements Interceptor {
final stopwatches = <String, Stopwatch>{};
@override