flutter_kanpur_ui_kit 0.0.3
flutter_kanpur_ui_kit: ^0.0.3 copied to clipboard
Flutter Kanpur Ui Kit Package
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_kanpur_ui_kit/flutter_kanpur_ui_kit.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
// Initialize ScreenUtil for responsive design
return ScreenUtilInit(
designSize: const Size(360, 690),
minTextAdapt: true,
splitScreenMode: true,
builder: (_, child) {
return MaterialApp(
title: 'Flutter Kanpur UI Kit Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: child,
);
},
child: const MyHomePage(title: 'Flutter Kanpur UI Kit Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _currentIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Selected Index: $_currentIndex',
style: Theme.of(context).textTheme.headlineMedium,
),
const SizedBox(height: 20),
Text(
_getPageName(_currentIndex),
style: Theme.of(context).textTheme.titleLarge,
),
],
),
),
// Use the BottomNavbar from the package
bottomNavigationBar: BottomNavbar(
currentIndex: _currentIndex,
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
),
);
}
String _getPageName(int index) {
switch (index) {
case 0:
return 'Home';
case 1:
return 'Search';
case 2:
return 'Create';
case 3:
return 'Trending';
case 4:
return 'Profile';
default:
return 'Unknown';
}
}
}