Last updated:
0 purchases
sdev flutter core
[sdev_flutter_core] is a package for all the boilerplate code
necessary when developing a flutter application.
Features #
Adapter interface
Common extensions for Date, Time, String
Navigation Utils
Responsiveness Utils
Storage Utils
Validator
Getting started #
Install the package as a dependency to start using it in your flutter app
Usage #
Date Extensions #
final date = DateTime.now();
print(date.stringify);
copied to clipboard
String Extensions #
"Message".showBottomSnackBar(context);
copied to clipboard
Time Extensions #
final time = TimeOfDay.now();
time.stringify;
copied to clipboard
Storing data easily via Storage classes #
Storing data to file
class Profile implements Serializable {
final String name;
Profile({required this.name});
@override
Map<String, dynamic> toMap() {
return {
"name": name,
};
}
}
copied to clipboard
class ProfileAdapter implements IAdapter<Profile, Map<String, dynamic>> {
@override
Profile convert(Map<String, dynamic> data) {
return Profile(name: data['name']);
}
}
copied to clipboard
class ProfileStoreRepo extends FileStoreRepo<Profile> {
ProfileStoreRepo({
super.filename = "profile.txt",
}) : super(adapter: ProfileAdapter());
}
copied to clipboard
final storeRepo = ProfileStoreRepo();
final Profile p = await network.fetchProfile();
await storeRepo.save(p);
copied to clipboard
final storeRepo = ProfileStoreRepo();
final savedProfile = await storeRepo.fetch();
if(savedProfile == null) {
print("No saved Profile Found");
}
copied to clipboard
Storing data to Shared Preferences
class Token implements Serializable {
final String accessToken;
Token({
required this.accessToken,
});
@override
Map<String, dynamic> toMap() {
return {
"access_token": accessToken,
};
}
}
class TokenAdapter implements IAdapter<Token, Map<String, dynamic>> {
@override
Token convert(Map<String, dynamic> data) {
return Token(accessToken: data['access_token']);
}
}
class TokenStoreRepo extends PrefsStoreRepo<Token> {
TokenStoreRepo({
required super.prefs,
super.key = "@token",
}) : super(adapter: TokenAdapter());
}
copied to clipboard
final storeRepo = TokenStoreRepo();
final Token p = await network.login(email, password);
await storeRepo.save(p);
copied to clipboard
final storeRepo = TokenStoreRepo();
final savedToken = await storeRepo.fetch();
if(savedProfile == null) {
print("No saved Token Found");
}
copied to clipboard
Using validators #
TextFormField(
validator: Validator.validateEmpty,
)
copied to clipboard
Additional information #
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.