bh_shared 0.0.2 bh_shared: ^0.0.2 copied to clipboard
Bianca's House shared package
bh_shared #
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 (based on HydratedBloc package)
- home page provider - use a home page for web and a different home page for mobile
- a dynamic page routing API (based on go_router)
- 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 BaseUseful, WidgetHelper, LocalStorage {}
Or, for your convenience, simply prefixany method with BaseGlobal.
Table of Contents #
- Local Storage API
- Home Page Provider API
- Routing Config Provider API
- Miscellaneous useful widgets and methods we found useful
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) {}
Home Page Provider API #
This API allows you to have 2 version of your home page: one for web and one for mobile. You supply both pages to the API and the appropriate one get used at runtime:
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: HomePageProvider().getWebOrMobileHomePage(
HomePageWeb(), HomePageMobile(),
),
);
}
Routing Config Provider API #
Making use of the go_router package, you use this API in a similar way to the Home Page Provider. You supply a go_router configuration for both web, and mobile. At runtime, the appropriate one gets used:
GoRouter router = GoRouter.routingConfig(
initialLocation: initialRoutePath,
routingConfig: RoutingConfigProvider().getWebOrMobileRoutingConfig(
widget.webRoutingConfig,
widget.mobileRoutingConfig,
));
Miscellaneous useful widgets and methods we found useful #
...to be added...
table test
spank | monkey | |||
---|---|---|---|---|