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
class MyApp extends StatelessWidget { | |
static final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); | |
Widget build(BuildContext context) { | |
final pushNotificationService = PushNotificationService(_firebaseMessaging); | |
pushNotificationService.initialise(); | |
// the rest of your build method | |
} | |
} |
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:firebase_messaging/firebase_messaging.dart'; | |
class PushNotificationService { | |
final FirebaseMessaging _fcm; | |
PushNotificationService(this._fcm); | |
Future initialise() async { | |
if (Platform.isIOS) { | |
_fcm.requestNotificationPermissions(IosNotificationSettings()); |
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_test/flutter_test.dart'; | |
import 'package:mocktail_image_network/mocktail_image_network.dart'; | |
testWidgets( | |
'renders an image with the provided image url', | |
(tester) async { | |
const expectedImageUrl = 'media.giphy.com/example.jpg'; | |
await mockNetworkImages(() async { | |
await tester.pumpWidget(app); // your app is a widget that contains your network image | |
/** You should also wrap your NetworkImage or Image.network with a DecoratedBox or other widget as the parent, |
OlderNewer