Skip to content
Snippets Groups Projects
main.dart 16.63 KiB
import 'dart:async';
import 'dart:io';

import 'package:connectivity_wrapper/connectivity_wrapper.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:feedback/feedback.dart';
import 'package:filesystem_picker/filesystem_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:introduction_screen/introduction_screen.dart';
import 'package:lehttp_overrides/lehttp_overrides.dart';
import 'package:once/once.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pwa_install/pwa_install.dart';
import 'package:responsive_framework/responsive_wrapper.dart';
import 'package:responsive_framework/utils/scroll_behavior.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_logging/sentry_logging.dart';
import 'package:uni_links/uni_links.dart';

import 'app_bloc_observer.dart';
import 'config/theme.dart';
import 'custom_feedback_localization.dart';
import 'data/models/app_cubit.dart';
import 'data/models/app_state.dart';
import 'data/models/bottom_nav_cubit.dart';
import 'data/models/contact_cubit.dart';
import 'data/models/node_list_cubit.dart';
import 'data/models/node_list_state.dart';
import 'data/models/node_manager.dart';
import 'data/models/node_type.dart';
import 'data/models/payment_cubit.dart';
import 'data/models/theme_cubit.dart';
import 'data/models/transaction_cubit.dart';
import 'g1/api.dart';
import 'g1/g1_helper.dart';
import 'shared_prefs.dart';
import 'ui/contacts_cache.dart';
import 'ui/logger.dart';
import 'ui/notification_controller.dart';
import 'ui/screens/skeleton_screen.dart';
import 'ui/ui_helpers.dart';
import 'ui/widgets/connectivity_widget_wrapper_wrapper.dart';
import 'ui/widgets/first_screen/contact_search_page.dart';

void main() async {
  await NotificationController.initializeLocalNotifications();

  // To resolve Let's Encrypt SSL certificate problems with Android 7.1.1 and below
  if (!kIsWeb && Platform.isAndroid) {
    HttpOverrides.global = LEHttpOverrides();
  }

  /// Initialize packages
  WidgetsFlutterBinding.ensureInitialized();
  await EasyLocalization.ensureInitialized();

  if (!kIsWeb && Platform.isAndroid) {
    await FlutterDisplayMode.setHighRefreshRate();
  }

  // .env
  await dotenv.load(
      fileName: kReleaseMode
          ? 'assets/env.production.txt'