starlight_utils 0.0.3
SDKflutter
Platformandroidioswindowslinuxmacos
The easiest way to use context less Navigation, Dialog, BottomSheet and many other useful functions such as String, num, context, MediaQuery....
Starlight Utils
The easiest way to use context less Navigation, Dialog, BottomSheet and many other useful functions such as String, num, context, MediaQuery....
Features
| Name | Status |
|---|---|
| Context Less Navigation Service | ✅ |
| Context Less Dialog | ✅ |
| Context Less Bottom Sheet | ✅ |
| Context Less Snackbar | ✅ |
| Context Less DatePicker | ✅ |
| Context Less TimePicker | ✅ |
| Easy Menu | ✅ |
| String Useful Function | ✅ |
| Num Useful Function | ✅ |
| List Useful Function | ✅ |
| Map Useful Function | ✅ |
| Date Useful Function | ✅ |
| Color Useful Function | ✅ |
| Responsive Useful Function | ✅ |
| MediaQuery Useful Function | ✅ |
| Theme Useful Function | ✅ |
ScreenShots
Installation
Add starlight_utils as dependency to your pubspec file.
starlight_utils:
git:
url: https://github.com/YeMyoAung/starlight_utils.git
Setup
No additional integration steps are required for Android and Ios.
Usage
At first, you need to import our package.
import 'package:starlight_utils/starlight_utils.dart';
And then you can use easily.
Context Less Navigation
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
StarlightUtils.push(MyHome());///`Navigation.push()` shortcut.
StarlightUtils.pushNamed('home');///`Navigation.pushNamed()` shortcut.
StarlightUtils.pushNamedAndRemoveUntil('home');///`Navigation.pushNamedAndRemoveUntil()` shortcut.
StarlightUtils.pushAndRemoveUntil(MyHome());///`Navigation.pushAndRemoveUntil()` shortcut.
StarlightUtils.pushReplacement(MyHome());///`Navigation.pushReplacement()` shortcut.
StarlightUtils.pushReplacementNamed('home');///`Navigation.pushReplacement()` shortcut.
StarlightUtils.popAndPushNamed('home');///`Navigation.popAndPushNamed()` shortcut.
///If you used a context(like this(StarlightUtils.of(context))),
///you need to invoke like this StarlightUtils.pop(usedContext:true)
StarlightUtils.pop();///`Navigation.pop()` shortcut.
StarlightUtils.conPop();///`Navigation.conPop()` shortcut.
return MaterialApp(
navigatorKey: StarlightUtils.navigatorKey,///important
);
}
}
About Dialog
class MyApp xtends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
width: context.width - 20,
height: 45,
child: ElevatedButton(
onPressed: StarlightUtils.aboutDialog,
child: const Text(
"aboutDialog",
),
),
);
}
}
Dialog
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
width: context.width - 20,
height: 45,
child: ElevatedButton(
onPressed: () {
StarlightUtils.dialog(AlertDialog(
title: Text("hello"),
));
},
child: const Text(
"dialog",
),
),
);
}
}
Bottomsheet
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
width: context.width - 20,
height: 45,
child: ElevatedButton(
onPressed: () {
StarlightUtils.bottomSheet(Container(
width: context.width,
height: 100,
child: Text("bottom sheet"),
));
},
child: const Text(
"bottomSheet",
),
),
);
}
}
Snackbar
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
width: context.width - 20,
height: 45,
child: ElevatedButton(
onPressed: () {
StarlightUtils.snackbar(SnackBar(content: Text('hello')));
},
child: const Text(
"snackbar",
),
),
);
}
}
Date Picker
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
StarlightUtils.of(context);///important
return SizedBox(
width: context.width - 20,
height: 45,
child: ElevatedButton(
onPressed: () {
StarlightUtils.datePicker(
initialDate: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime(2100),
);
},
child: const Text(
"datePicker",
),
),
);
}
}
TimePicker
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
StarlightUtils.of(context);///important
return SizedBox(
width: context.width - 20,
height: 45,
child: ElevatedButton(
onPressed: () {
StarlightUtils.timePicker(
initialTime: TimeOfDay.fromDateTime(
DateTime.now(),
),
);
},
child: const Text(
"timePicker",
),
),
);
}
}
dateRangePicker
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
StarlightUtils.of(context);///important
return SizedBox(
width: context.width - 20,
height: 45,
child: ElevatedButton(
onPressed: () {
StarlightUtils.dateRangePicker(
firstDate: DateTime(2000),
lastDate: DateTime(2100),
);
},
child: const Text(
"dateRangePicker",
),
),
);
}
}
Menu
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
StarlightUtils.of(context);///important
return Scaffold(
appBar: AppBar(
actions: [
IconButton(
onPressed: () {
StarlightUtils.menu(
position: RelativeRect.fromLTRB(10, 0, 0, 0),
items: [
PopupMenuItem(child: Text('item 1')),
PopupMenuItem(child: Text('item 2')),
PopupMenuItem(child: Text('item 3')),
],
);
},
icon: Icon(Icons.more_vert),
)
],
),
);
}
}
Easy Menu
class TestSocketScreen extends StatelessWidget {
const TestSocketScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return StarlightEasyMenu(
childBuilder: (context, controller) => StreamBuilder<bool>(
initialData: false,
stream: stream,
builder: (_, snapshot) {
return AnimatedIcon(
icon: snapshot.data == true
? AnimatedIcons.menu_close
: AnimatedIcons.arrow_menu,
progress: kAlwaysCompleteAnimation,
);
},),
menuBuilder:(context, controller) => Container(
width: 200,
height: 120,
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ListTile(
onTap: controller.hideMenu,
title: Row(
children: const [
Icon(Icons.settings),
SizedBox(
width: 10,
),
Text("Setting"),
],
),
),
ListTile(
onTap: controller.hideMenu,
title: Row(
children: const [
Icon(Icons.help),
SizedBox(
width: 10,
),
Text("Help"),
],
),
),
],
),
),
);
}
}
String
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
print("Hello World".toValidate);///helloworld
print("a b c".withoutWhiteSpace);///abc
print("a@".isEmail);///false
print("password".isStrongPassword(
checkUpperCase:true,
checkLowerCase:true,
checkDigit:true,
checkSpecailChar:true,
minLength:6
));///null or requirement
final File file = "file_path".file;///File Instance
final Uri uri = "http://url.com".uri;///Uri Instance
return Container();
}
}
num
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
print(1.ordinal);///1st (String)
print(2.ordinal);///2nd (String)
print(100000.currencyFormat);///100,000 (String)
print(1000.humanReadAble(useLowerCase:true));///1k (String)
return Container();
}
}
List
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
print(["Starlight Studio",{"name":"Starlight Studio"}].equal(["Starlight Studio",{"name":"Starlight Studio"}]));///true
print([1,2,3,4,5,6].chunk(2));///[[1,2],[3,4],[5,6]]
return Container();
}
}
Map
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
print({"name":"Starlight Studio",
"in_list":[
"Starlight Studio"]
}.equal({"name":"Starlight Studio",
"in_list":[
"Starlight Studio"]
}));///true
return Container();
}
}
Responsive
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
10.w(context);/// Returns a calculated width based on the device
10.h(context);/// Returns a calculated height based on the device
3.sp(context);///Returns a calculated sp based on the device
return Container();
}
}
MediaQuery
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
context.with;///device width
context.height;///device height
context.devicePixelRatio;///device pixel ratio
context.textScaleFactor;///text scale factor
context.topSafe;///Appbar height
context.bottomSafe;///bottom navigationbar height
context.orientation;///Device orientation
context.invertColors;///is inverting Colors or not
context.highContrast;///is highContrast or not
context.gestureSettings;///gesture settings
context.boldText;///is bold text or not
context.alwaysUse24HourFormat;///is using 24 hour format or not
context.accessibleNavigation;///is accessible navigation or not
context.viewInsets;//ToHandle Keyboard is show or hide
return Container();
}
}
Date
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
print(DateTime.now().monthformat(MonthFormat.long));///February
print(DateTime.now().monthformat(MonthFormat.short));///Feb
print(DateTime.now().monthformat(MonthFormat.ordinal));///2nd
print(DateTime.now().monthformat(MonthFormat.none));///2
print(DateTime.now().isLeapYear);///false
print(DateTime.now().maxDay);///28
print(DateTime(2022, 2, 2).differenceTimeInString(DateTime(2022, 2, 1)));//24h
return Container();
}
}
Theme
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
context.theme;///ThemeData
return Container();
}
}