Last updated:
0 purchases
obm tools
Getting started #
Installing #
Add this to your package's pubspec.yaml file:
dependencies:
obm_tools: ^latest
copied to clipboard
Import #
import 'package:obm_tools/obm_tools.dart';
copied to clipboard
Usage #
get screen size #
// Screen Size High
double height = ScreenSize(context).height;
// Screen Size Width
double width = ScreenSize(context).width;
copied to clipboard
get time by timezone #
getTimeZone() {
Timer.periodic(const Duration(seconds: 1), (timer) async {
DateTime dateTime = await ObmTools().getDateTime(timeZone ?? "Asia/Jakarta");
setState(() {
time = DateFormat("yyyy-MM-dd HH:mm:ss").format(dateTime);
});
});
}
copied to clipboard
get connectifity #
Future<bool> checkConnection() async {
var connectivityResult = await ObmTools().connection();
setState(() {
connections = connectivityResult!.name;
});
// connectivityResult.name = "wifi" / "mobile"
switch (connectivityResult!.name) {
case "mobile":
return true;
case "wifi":
return true;
default:
return false;
}
}
copied to clipboard
get ip address #
getIp() async {
var ip = await ObmTools().getIpAddress();
setState(() {
ipAddress = ip;
});
}
copied to clipboard
Custom Text Form Field widget and Email Validator #
ObmTextFormField(
controller: emailController,
autoFocus: false,
textInputAction: TextInputAction.next,
keyboardType: TextInputType.emailAddress,
labelText: "Email",
validator: (input) {
if (input!.isEmpty) {
return "Input your email";
} else {
// email validator
if (!(EmailValidator.validate(input))) {
return "Input your valid Email";
} else {
return null;
}
}
},
prefixIcon: const Icon(
Icons.account_circle_outlined,
color: Colors.black,
),
hintText: "Email",
),
copied to clipboard
Custom Text Form Field with currency formater #
ObmTextFormField(
controller: currencyController,
autoFocus: false,
isCurrency: true,
prefixText: currencyController.text.isEmpty ? '' : 'Rp ',
currencyCodeZone: "id_ID",
textInputAction: TextInputAction.next,
keyboardType: TextInputType.number,
labelText: "Amount Money",
validator: (input) {
if (input!.isEmpty) {
return "Input your amount money";
} else {
return null;
}
},
hintText: "Rp 1.500.000",
),
copied to clipboard
Custom Button #
ObmButton(
buttonLabel: "Submit",
buttonWidth: double.infinity,
buttonColor: Colors.orange,
borderRadius: 5.0,
press: () {
submit();
},
),
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.