Skip to content

Instantly share code, notes, and snippets.

View slightfoot's full-sized avatar
💙
Fluttering

Simon Lightfoot slightfoot

💙
Fluttering
View GitHub Profile
@slightfoot
slightfoot / bubble_effect.dart
Created March 18, 2021 00:42
3D Style Bubble Magnifying Effect - by Simon Lightfoot and Wilson Wilson @wilsonowilson - 18/03/2021
// MIT License
//
// Copyright (c) 2021 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@slightfoot
slightfoot / image_aspect_1.dart
Last active February 4, 2024 09:52
Dart code to resize an image and keep aspect ratio using Image package.
import 'package:image/image.dart' as image;
// Ex: Image newImage = scaleImageCentered(oldImage, 512, 512, image.getColor(0, 0, 255));
image.Image scaleImageCentered(image.Image source, int maxWidth, int maxHeight, int colorBackground) {
final double scaleX = source.width / maxWidth;
final double scaleY = source.height / maxHeight;
final double scale = (scaleX * source.height > maxHeight) ? scaleY : scaleX;
final int width = (source.width * scale).round();
final int height = (source.height * scale).round();
return image.drawImage(
@slightfoot
slightfoot / bottom_sheet.dart
Last active February 1, 2024 18:24
Modal Bottom Sheet with Input Fields fix for Flutter (Fix issue with overlap with keyboard and fix for tapping to dismiss)
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
@slightfoot
slightfoot / humpday_310124_2.dart
Created January 31, 2024 19:51
Chat Message photo stack example - by Simon Lightfoot - Humpday Q&A :: 31st January 2024 #Flutter #Dart https://www.youtube.com/watch?v=YS_g2TJN-cQ
// MIT License
//
// Copyright (c) 2023 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@slightfoot
slightfoot / humpday_310124_1.dart
Created January 31, 2024 19:18
ListView ratios example - by Simon Lightfoot - Humpday Q&A :: 31st January 2024 #Flutter #Dart https://www.youtube.com/watch?v=YS_g2TJN-cQ
// MIT License
//
// Copyright (c) 2023 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@slightfoot
slightfoot / stream_text.dart
Last active January 30, 2024 06:45
Streaming Text in Flutter
import 'dart:async';
import 'package:flutter/material.dart';
void main() =>
runApp(MaterialApp(
home: ExampleScreen(),
));
class ExampleScreen extends StatelessWidget {
@slightfoot
slightfoot / humpday_240124.dart
Last active January 24, 2024 21:33
Flutter Web IFrame Embed - by Simon Lightfoot - Humpday Q&A :: 24th January 2024 #Flutter #Dart https://www.youtube.com/watch?v=tVAqEC8R3Q8
// MIT License
//
// Copyright (c) 2023 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@slightfoot
slightfoot / humpday_100124_section_scrolling.dart
Created January 10, 2024 21:35
Section Scrolling - by Simon Lightfoot - Humpday Q&A :: 10th January 2024 #Flutter #Dart https://www.youtube.com/watch?v=4YQG41-cLu4
// MIT License
//
// Copyright (c) 2023 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@slightfoot
slightfoot / main.dart
Last active January 2, 2024 05:53
Flutter Drop List Example with TextField
import 'package:flutter/material.dart';
void main()
{
final TextEditingController _controller = new TextEditingController();
var items = ['Working a lot harder', 'Being a lot smarter', 'Being a self-starter', 'Placed in charge of trading charter'];
runApp(
new MaterialApp(
title: 'Drop List Example',
home: new Scaffold(
@slightfoot
slightfoot / humpday_131223.dart
Last active December 27, 2023 20:24
Example of state management without Libraries - by Simon Lightfoot - Humpday Q&A :: 13th December 2023 #Flutter #Dart - https://www.youtube.com/live/7k_tMJF1B-0?si=l5u-AN9YrpN_il9i&t=4402
// MIT License
//
// Copyright (c) 2023 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: