This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:meta/meta.dart'; | |
| /// Dart implementation of Swift's `Optional` type. | |
| /// | |
| /// {@template optional} | |
| /// Creates an object that holds a nullable value which can be unwrapped | |
| /// safely. | |
| /// {@endtemplate} | |
| /// | |
| /// Swift specs: https://developer.apple.com/documentation/swift/optional |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/foundation.dart'; | |
| import 'package:flutter/material.dart'; | |
| void main() => runApp(const MyApp()); | |
| class MyApp extends StatelessWidget { | |
| const MyApp({super.key}); | |
| @override | |
| Widget build(BuildContext context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:convert'; | |
| import 'dart:math'; | |
| import 'package:crypto/crypto.dart'; | |
| int generateId(String name, String lang, int versionId) { | |
| String key = "${name.toLowerCase()}/$lang/$versionId"; | |
| List<int> bytes = md5.convert(utf8.encode(key)).bytes; | |
| int result = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// A [ChangeNotifier] that listens to multiple [Listenable]s. | |
| class RefreshNotifier extends ChangeNotifier { | |
| RefreshNotifier(this._listenables) { | |
| for (final listenable in _listenables) { | |
| listenable.addListener(notifyListeners); | |
| } | |
| } | |
| final List<Listenable> _listenables; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:async/async.dart'; | |
| import 'package:flutter/material.dart'; | |
| final navigatorKey = GlobalKey<NavigatorState>(); | |
| class InactivityObserver extends StatefulWidget { | |
| const InactivityObserver({ | |
| super.key, | |
| required this.inactivityTimeout, | |
| required this.child, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:flutter_riverpod/flutter_riverpod.dart'; | |
| class LocalizationNotifier extends StateNotifier<Locale?> { | |
| LocalizationNotifier({ | |
| required this.defaultLocale, | |
| required this.supportedLocales, | |
| }) : super(defaultLocale); | |
| final Locale defaultLocale; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", |
NewerOlder