Skip to content

Instantly share code, notes, and snippets.

View TesteurManiak's full-sized avatar
🎯
Dart/Flutter Software Engineer

Guillaume Roux TesteurManiak

🎯
Dart/Flutter Software Engineer
View GitHub Profile
@TesteurManiak
TesteurManiak / main.dart
Created October 14, 2020 12:52
flutter_fcm_web_example/main.dart
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_fcm_web_example/my_app.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
@TesteurManiak
TesteurManiak / index.html
Last active October 14, 2020 14:53
flutter_fcm_web_example/index1.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
import 'package:flutter_fcm_web_example/notification_model.dart';
abstract class NotificationHelper {
Future<bool> get isReady;
Stream<NotificationModel> get stream;
void close();
Future<String> getToken([bool force = false]);
Future<dynamic> requestPermission();
}
import 'dart:async';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_fcm_web_example/notification_helper.dart';
import 'package:flutter_fcm_web_example/notification_model.dart';
/// Mobile-only helper to manage notifications.
class FirebaseMessagingHelper implements NotificationHelper {
FirebaseMessagingHelper._internal();
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter_fcm_web_example/notification_helper.dart';
import 'package:firebase/firebase.dart' as firebaseWeb;
import 'package:flutter_fcm_web_example/notification_model.dart';
/// Web-only helper to manage notifications.
class FirebaseMessagingHelper implements NotificationHelper {
FirebaseMessagingHelper._internal();
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
importScripts('https://www.gstatic.com/firebasejs/7.23.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/7.23.0/firebase-messaging.js');
var firebaseConfig = {
apiKey: "API_KEY",
authDomain: "AUTH_DOMAIN",
databaseURL: "DB_URL",
projectId: "PROJECT_ID",
storageBucket: "STORAGE_BUCKET",
messagingSenderId: "SENDER_ID",
import 'package:flutter_fcm_web_example/notification_helper.dart';
import 'firebase_mobile_messaging.dart'
if (dart.library.js) 'firebase_web_messaging.dart' as notifInstance;
abstract class NotificationEncapsulation {
static NotificationHelper get instance =>
notifInstance.FirebaseMessagingHelper();
}
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_fcm_web_example/notification_encapsulation.dart';
import 'package:flutter_fcm_web_example/notification_model.dart';
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@TesteurManiak
TesteurManiak / sliver_separated_child_builder_delegate.dart
Created December 5, 2022 16:42
Showcase of SliverSeparatedChildBuilderDelegate
import 'dart:math' as math;
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
final elements = List<int>.generate(100, (i) => i);
void main() {
runApp(MyApp());