nb_utils 4.2.15+6
nb_utils: ^4.2.15+6 copied to clipboard
This package helps you daily usable function with ease. Just add nb_utils with its latest version and that's it you are ready to use.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:nb_utils/nb_utils.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initialize(aLocaleLanguageList: [
LanguageDataModel(name: 'English', languageCode: 'en'),
LanguageDataModel(name: 'Hindi', languageCode: 'hi'),
]);
selectedLanguageDataModel = getSelectedLanguageModel();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
init();
}
Future<void> init() async {
//
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'NB Utils Example',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: createMaterialColor(Colors.blue),
scaffoldBackgroundColor: scaffoldLightColor,
),
darkTheme: ThemeData(
primarySwatch: createMaterialColor(Colors.blue),
),
themeMode:
getIntAsync(THEME_MODE_INDEX) == 2 ? ThemeMode.dark : ThemeMode.light,
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
GlobalKey<FormState> formKey = GlobalKey();
double rating = 2.2;
@override
void initState() {
super.initState();
init();
}
Future<void> init() async {
//
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: appBarWidget('Home', showBack: Navigator.canPop(context)),
body: Container(
child: SingleChildScrollView(
child: Form(
key: formKey,
child: Column(
children: <Widget>[
ThemeWidget(
onThemeChanged: (data) {
log(data);
},
),
LanguageListWidget(
widgetType: WidgetType.DROPDOWN,
onLanguageChange: (data) {
log(data.name);
},
),
16.height,
DottedBorderWidget(
child: Container(
height: 100,
width: 100,
),
),
16.height,
///
Text('Rating Bar Widget Example', style: primaryTextStyle()),
8.height,
RatingBarWidget(
rating: rating,
onRatingChanged: (e) {
rating = e;
},
),
16.height,
/// Hover Widget Example
Text('Hover Widget Example', style: primaryTextStyle()),
8.height,
HoverWidget(
builder: (_, isHovering) {
return AnimatedContainer(
height: 100,
width: 100,
decoration: boxDecorationDefault(
color: isHovering ? Colors.blue : Colors.white,
borderRadius: radius(isHovering ? 50 : null),
),
duration: 400.milliseconds,
);
},
),
Column(
children: [
Wrap(
spacing: 16,
runSpacing: 16,
children: [
AppButton(
text: "Confirmation",
onTap: () {
showConfirmDialogCustom(
context,
onAccept: () {
snackBar(
context,
title: 'Confirmed',
snackBarAction: SnackBarAction(
label: 'label', onPressed: () {}),
);
},
);
},
),
AppButton(
text: "Confirmation with Custom Image",
onTap: () async {
showConfirmDialogCustom(
context,
title: "Do you want to logout from the app?",
dialogType: DialogType.CONFIRMATION,
centerImage:
'https://images.unsplash.com/photo-1579154392429-0e6b4e850ad2?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=397&q=80',
onAccept: () {
//
},
onCancel: () {
//
},
height: 300,
width: 400,
);
},
),
AppButton(
text: "Update",
onTap: () {
showConfirmDialogCustom(
context,
title: "Do you want to update this item?",
dialogType: DialogType.UPDATE,
onAccept: () {
snackBar(context, title: 'Updated');
},
);
},
),
AppButton(
text: "Delete",
onTap: () {
showConfirmDialogCustom(
context,
title: "Delete 89 files permanent?",
dialogType: DialogType.DELETE,
onAccept: () {
snackBar(context, title: 'Deleted');
},
);
},
),
AppButton(
text: "Add",
onTap: () {
showConfirmDialogCustom(
context,
title: "Do you want to add this item?",
dialogType: DialogType.ADD,
onAccept: () {
snackBar(context, title: 'Added');
},
);
},
),
],
),
16.height,
UL(
symbolType: SymbolType.Numbered,
children: [
Text('Hi', style: primaryTextStyle()),
Text('Hello', style: primaryTextStyle()),
Text('How are you?', style: primaryTextStyle()),
],
),
16.height,
UL(
children: [
Text('Hi', style: primaryTextStyle()),
Text('Hello', style: primaryTextStyle()),
Text(
'How are you? How are you? How are you? How are you? How are you? How are you? How are you? How are you? How are you? How are you?',
style: primaryTextStyle()),
],
),
16.height,
/// Default AppTextField
AppTextField(
textFieldType: TextFieldType.OTHER,
decoration: defaultInputDecoration(),
),
8.height,
/// Email TextField
AppTextField(
textFieldType: TextFieldType.EMAIL,
decoration: defaultInputDecoration(label: 'Email'),
),
8.height,
/// Address TextField
AppTextField(
textFieldType: TextFieldType.ADDRESS,
decoration: defaultInputDecoration(label: 'Address'),
minLines: 4,
),
8.height,
/// Password TextField
AppTextField(
textFieldType: TextFieldType.PASSWORD,
decoration: defaultInputDecoration(label: 'Password'),
),
],
).paddingAll(16),
16.height,
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GoogleLogoWidget(),
16.width,
AppButton(
text: 'Save',
onTap: () async {
if (formKey.currentState!.validate()) {
formKey.currentState!.save();
}
toast('Sample toast');
},
),
],
),
8.height,
SettingSection(
title: Text('Account Management',
style: boldTextStyle(size: 24)),
subTitle: Text('Control your account',
style: primaryTextStyle(size: 16)),
items: [
SettingItemWidget(
title: 'Hibernate account',
subTitle: 'Temporary deactivate your account',
decoration: BoxDecoration(borderRadius: radius()),
trailing: Icon(Icons.keyboard_arrow_right_rounded,
color: context.dividerColor),
onTap: () {
//
},
),
SettingItemWidget(
title: 'Close account',
subTitle:
'Learn about your options, and close your account if you wish',
decoration: BoxDecoration(borderRadius: radius()),
trailing: Icon(Icons.keyboard_arrow_right_rounded,
color: context.dividerColor),
onTap: () {
HomePage().launch(context);
},
),
],
),
],
),
),
),
),
);
}
}