import 'dart:io';
import 'package:bestapp_package/bestapp_package.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:tacban/config.dart';
import 'package:tacban/src/app/tacban_app.dart';
import 'package:tacban/src/shared/controllers/app_controller.dart';

class MyHttpOverrides extends HttpOverrides{
  @override
  HttpClient createHttpClient(SecurityContext? context){
    return super.createHttpClient(context)
      ..badCertificateCallback = ((X509Certificate cert, String host, int port) {
        return true;
      });
  }
}

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await dotenv.load(fileName: ".env");
  HttpOverrides.global = MyHttpOverrides();
  final ApiServices apiServices = ApiServices(
    showLogs: true,
    baseUrl: Config.baseApi,
  );
  
  runApp(
    ProviderScope(
      overrides: [
        apiServicesProvider.overrideWithValue(apiServices),
      ],
      child: const TecBanApp()
    )
  );
}