Skip to content

Instantly share code, notes, and snippets.

View FlutterWiz's full-sized avatar
🎯
Discipline

FlutterWiz FlutterWiz

🎯
Discipline
View GitHub Profile
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:todo_list_riverpod/domain/todo_model.dart';
part 'todo_state.freezed.dart';
@freezed
class TodoState with _$TodoState {
factory TodoState({
required List<TodoModel> todoList,
required TodoModel todo,
dependencies:
flutter:
sdk: flutter
freezed_annotation: ^2.0.3
flutter_riverpod: ^1.0.4
uuid: ^3.0.6
sizer: ^2.0.15
dev_dependencies:
import 'package:freezed_annotation/freezed_annotation.dart';
part 'todo_model.freezed.dart';
@freezed
class TodoModel with _$TodoModel {
const factory TodoModel({
required String id,
required String title,
required bool isTodoCompleted,
listener: (context, state) {
timerController!.duration = state.durationOfTimer;
if (state.isTimerReset) {
timerController!.reset();
NotificationApi.notifications.cancelAll();
}
if (state.isTimerStopped) {
timerController!.stop();
NotificationApi.notifications.cancelAll();
class AppWidget extends StatelessWidget {
const AppWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return BlocBuilder<LocalizationCubit, LocalizationState>(
builder: (context, state) {
return MaterialApp(
navigatorKey: navigatorKey,
locale: state.appLanguage,
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_native_timezone/flutter_native_timezone.dart';
import 'package:rxdart/rxdart.dart';
import 'package:timezone/timezone.dart' as tz;
import 'package:timezone/data/latest.dart' as time_zone;
class NotificationApi {
static const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings('timer.png');
static final notifications = FlutterLocalNotificationsPlugin();
import 'package:flutter/material.dart';
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
import 'package:flutter/material.dart';
import 'package:piva/infrastructure/localization/localized_values.dart';
import 'package:format/format.dart';
class PivaLocalizations {
PivaLocalizations(this.locale);
final Locale locale;
static PivaLocalizations of(BuildContext context) {
// first, set the language, then set the key and value.
const localizedValues = {
'en': {
"timeIsUpTitle": "Time is Up!",
"timeIsUpBody": "Wooosh, it's time to give a break!",
"reset": "Reset",
"stop": "Stop",
"start": "Start",
"hours": "Hours",
"minutes": "Minutes",
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:piva/infrastructure/localization/piva_localization.dart';
class PivaLocalizationsDelegate extends LocalizationsDelegate<PivaLocalizations> {
const PivaLocalizationsDelegate();
@override
bool isSupported(Locale locale) => true;