kitforge 0.2.1
kitforge: ^0.2.1 copied to clipboard
An all-in-one Flutter toolkit — permissions, connectivity, toast, dialogs, bottom sheets, animation helpers, navigation, storage, logging, HTTP, validators, OTP fields, image/camera picking, lo[...]
import 'package:flutter/material.dart';
import 'package:kitforge/kitforge.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await KitStorage.init();
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey:
KitNavigation.navigatorKey, // required for context-free modules
title: 'KitForge Example',
theme: ThemeData(colorSchemeSeed: Colors.indigo, useMaterial3: true),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('KitForge')),
body: KitNetworkBanner(
onlineText: 'Back online',
child: ListView(
padding: const EdgeInsets.all(16),
children: [
KitFadeIn(child: const Text('Toast, dialogs & sheets')),
const SizedBox(height: 12),
Wrap(
spacing: 8,
runSpacing: 8,
children: [
ElevatedButton(
onPressed: () => KitToast.success('Saved successfully'),
child: const Text('Show toast'),
),
ElevatedButton(
onPressed: () async {
final ok = await KitDialogs.confirm(
title: 'Delete item?',
message: 'This cannot be undone.',
isDestructive: true,
);
if (ok == true) KitToast.error('Deleted');
},
child: const Text('Confirm dialog'),
),
ElevatedButton(
onPressed: () => KitBottomSheet.actions<String>(
title: 'Choose an action',
[
const KitSheetAction(
label: 'Share', value: 'share', icon: Icons.share),
const KitSheetAction(
label: 'Delete',
value: 'delete',
icon: Icons.delete,
isDestructive: true,
),
],
),
child: const Text('Action sheet'),
),
],
),
const Divider(height: 32),
const Text('OTP field'),
const SizedBox(height: 8),
KitOtpField(
length: 4, onCompleted: (code) => KitToast.show('Code: $code')),
const Divider(height: 32),
ElevatedButton(
onPressed: () async {
final result =
await KitPermission.request(KitPermissionType.location);
result.when(
success: (_) =>
KitToast.success('Location permission granted'),
failure: (message, _) => KitToast.error(message),
);
},
child: const Text('Request location permission'),
),
],
),
),
);
}
}