os_basecode 0.1.14
os_basecode: ^0.1.14 copied to clipboard
Reusable Flutter utilities and common infrastructure for clean architecture apps.
example/main.dart
import 'package:flutter/material.dart';
import 'package:os_basecode/os_basecode.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
initInjector();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
static final _router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (context, state) => Scaffold(
appBar: AppBar(title: const Text('os_basecode example')),
body: const Center(child: Text('Package example is running.')),
),
),
],
);
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(390, 844),
builder: (context, child) => MaterialApp.router(
title: 'os_basecode example',
routerConfig: _router,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF133A94),
),
useMaterial3: true,
),
darkTheme: ThemeData.dark(useMaterial3: true),
),
);
}
}
final locator = GetIt.instance;
void initInjector() {
locator.registerFactory<Client>(
() => Client(
baseURL: 'https://api.example.com',
accessTokenKey: 'access_token',
showLogging: true,
headers: const {},
hitCacheOnErrorExcept: const [500],
handleWhenUnauthorized: () => debugPrint('API session expired.'),
),
);
locator.registerFactory<Dio>(() => locator<Client>().dioService);
}