Skip to content

Instantly share code, notes, and snippets.

@funwithflutter
funwithflutter / user_repository.dart
Last active June 22, 2021 04:50
Flutter Web Firebase Auth
import 'package:firebase/firebase.dart';
import 'package:meta/meta.dart';
@immutable
class UserRepository {
UserRepository({Auth firebaseAuth, GoogleAuthProvider googleSignin})
: _firebaseAuth = firebaseAuth ?? auth(),
_googleSignIn = googleSignin ?? GoogleAuthProvider();
final Auth _firebaseAuth;
@funwithflutter
funwithflutter / index.html
Created September 23, 2019 08:53
Firebase JavaScript init
<body>
<!-- Previously loaded Firebase SDKs -->
<script>
// TODO: Replace the following with your app's Firebase project configuration
var firebaseConfig = {
// ...
};
// Initialize Firebase
@funwithflutter
funwithflutter / user_repository.dart
Created September 23, 2019 11:38
Flutter Web Dart Firebase Email/Password Signin
Future<UserCredential> signInWithCredentials(
String email, String password) async {
try {
return await _firebaseAuth.signInWithEmailAndPassword(email, password);
} catch (e) {
print('Error in sign in with credentials: $e');
throw '$e';
}
}
@funwithflutter
funwithflutter / main_add_self_signed_certificate.dart
Created December 3, 2019 03:59
Add a self-signed certificate to a Flutter application
void main() {
ByteData data = await rootBundle.load('assets/raw/certificate.pem');
SecurityContext context = SecurityContext.defaultContext;
context.setTrustedCertificatesBytes(data.buffer.asUint8List());
runApp(MyApp());
}
@funwithflutter
funwithflutter / main_add_self_signed_certificate_debug.dart
Created December 3, 2019 04:03
Add a self-signed certificate to a Flutter application but only for Debug builds
Future<bool> addSelfSignedCertificate() async {
ByteData data = await rootBundle.load('assets/raw/certificate.pem');
SecurityContext context = SecurityContext.defaultContext;
context.setTrustedCertificatesBytes(data.buffer.asUint8List());
return true;
}
void main() async {
assert(await addSelfSignedCertificate());
runApp(MyApp());
@funwithflutter
funwithflutter / main.dart
Last active August 10, 2021 21:16
Flutter Animation Controller example
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
@funwithflutter
funwithflutter / main.dart
Last active August 10, 2021 21:17
Example of an animation status listener
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
@funwithflutter
funwithflutter / hint.txt
Last active August 10, 2021 20:56
Tweens example
Call .chain on the _widthTween and then give a CurveTween, to create an Animatable.
@funwithflutter
funwithflutter / implicit_animation_game.dart
Last active July 9, 2021 19:10
Flutter Implicit Animation Game
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@funwithflutter
funwithflutter / main.dart
Last active August 10, 2021 21:18
Flutter Animation object examples
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,