Notification in Flutter
Notification in Flutter
Notification in Flutter
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:instagram/utilities/custom_navigation.dart';
import 'package:instagram/utilities/themes.dart';
import 'package:instagram/common_widgets/user_badges.dart';
import 'package:timeago/timeago.dart' as timeago;
import 'package:instagram/services/services.dart';
import 'package:instagram/models/models.dart';
import 'package:instagram/screens/screens.dart';
import 'package:instagram/utilities/constants.dart';
ActivityScreen({this.currentUser});
@override
_ActivityScreenState createState() => _ActivityScreenState();
}
await fltrNotification.show(
0, title, description, generalNotificationDetails,
payload: "Task");
// var scheduledTime = DateTime.now().add(Duration(seconds: 0));
// fltrNotification.schedule(
// 1, "Time", "Notification", scheduledTime, generalNotificationDetails);
}
_setupActivities() async {
setState(() => _isLoading = true);
List<Activity> activities =
await DatabaseService.getActivities(widget.currentUser.id);
if (mounted) {
setState(() {
_activities = activities;
_isLoading = false;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).appBarTheme.color,
title: Text(
'Activity',
),
),
body: RefreshIndicator(
onRefresh: () => _setupActivities(),
child: _isLoading
? Center(
child: CircularProgressIndicator(),
)
: ListView.builder(
itemCount: _activities.length,
itemBuilder: (BuildContext context, int index) {
Activity activity = _activities[index];
isLast = false;
if (index == 0) {
isLast = true;
}
if (activity.isMessageEvent == true ||
activity.isLikeMessageEvent == true) {
return SizedBox.shrink();
}
return _buildActivity(activity, isLast);
},
),
),
);
}
}