bh_shared 3.0.0
bh_shared: ^3.0.0 copied to clipboard
bh_shared package now rolled into flutter_callout package
bh_shared (package functionality is relocated to another package) #
*** this library defunct: now rolled into flutter_callout package *** #
#
#
A collection of useful APIs and flutter widgets that are used in our other packages:
- flutter_callouts
- flutter_content
Hopefully, they may be useful for you in your apps.
Motivation #
It's sensible to centralise your reusable source code into a separate library.
Features #
- a local storage API
- gotits API (based on local storage)
- debounce timer
- some useful widgets
Quickstart #
1. Install or update package bh_shared:
flutter pub add bh_shared
- How to include in your apps you can add the functionality of the API to your own dart classes using the with keyword.
class MyClass with SystemMixin, WidgetHelperMixin, GotitsMixin, LocalStorageMixin, CanvasMixin {}
Or, for your convenience, simply prefix any method with base.
Table of Contents #
Usage #
Local Storage API #
Local storage refers to browser storage on web, and device storage on mobile.
Future<void> localStorage_init() async {}
dynamic localStorage_read(String name) {}
Future<void> localStorage_write(String name, dynamic value) async {}
void localStorage_clear() {}
void localStorage_delete(String name) {}
Gotits API #
This API is useful if you want to allow the user to specify that help has been seen and to not show again. A map of named booleans is stored in local storage. Also a useful widget is provided.
Future<void> gotit(String feature, {bool notUsingHydratedStorage = false})
bool alreadyGotit(String feature, {bool notUsingHydratedStorage = false})
void clearGotits({bool notUsingHydratedStorage = false})
Widget gotitButton({required String feature,
required double iconSize,
bool notUsingHydratedStorage = false})
Debouncer API #
An instance of DebounceTimer is useful for timing out events, such as repeated keypresses:
class DebounceTimer {
int delayMs;
Timer? _timer;
DebounceTimer({required this.delayMs});
void run(VoidCallback action) {
_timer?.cancel();
_timer = Timer(Duration(milliseconds: delayMs), action);
}
void cancel() {
_timer?.cancel();
}
}
Issues & Feedback #
Please file an issue to send feedback or report a bug. Thank you!