os_basecode 0.1.4 copy "os_basecode: ^0.1.4" to clipboard
os_basecode: ^0.1.4 copied to clipboard

A Core Package That Must Have on every flutter project if using Clean Code Architecture

example/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:os_basecode/os_basecode.dart';

void main() {
  runApp(DevicePreview(
    enabled: !kReleaseMode,
    builder: (context) => const MyApp(),
  ));
  initInjector();
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: ScreenUtil.defaultSize,
      builder: (context, child) => MaterialApp.router(
        locale: DevicePreview.locale(context),
        builder: DevicePreview.appBuilder,
        title: 'YOUR APPLICATION',
        theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: "#133a94".toColor()),
            useMaterial3: true,
            visualDensity: VisualDensity.adaptivePlatformDensity,
            textTheme: GoogleFonts.plusJakartaSansTextTheme()),
        darkTheme: ThemeData.dark(
          useMaterial3: true,
        ),
      ),
    );
  }
}

var locator = GetIt.instance;

void initInjector() {
  locator.registerFactory<Dio>(() => Client(
      baseURL: "http://localhost.com",
      showLogging: true,
      headers: {},
      hitCacheOnErrorExcept: [500],
      handleWhenUnauthorized: () {
        print("401 Error From Dio");
      }).init());
}