frontegg 0.0.3
frontegg: ^0.0.3 copied to clipboard
Flutter package for Frontegg services
Frontegg-Flutter
Flutter Web pre-built Component for faster and simpler integration with Frontegg services.
Installation #
Frontegg-Flutter is available as an pub.dev package.
1. Add frontegg package to pubspec.yaml dependencies:
dependencies:
frontegg:
Add script tag to the main HTML template file:
[VERSION] may be latest, next or specific versions.
<body>
<!-- set frontegg the first script -->
<script src="https://assets.frontegg.com/admin-box/frontegg/[VERSION].js"></script>
<!-- other scripts -->
</body>
Initialize Frontegg App:
- Use
setUrlStrategy(PathUrlStrategy());to be able to work with frontegg routes - Edit main.dart file:
void main(){ fronteggApp = initialize(FronteggOptions( version: 'next', contextOptions: ContextOptions( baseUrl: 'https://[HOST_NAME].frontegg.com', requestCredentials: 'include' ) )); /** * wait for frontegg to be loaded and then runApp */ fronteggApp.onLoad(allowInterop(() { runApp(MyApp()); })); } - In order to observe to changes in Frontegg store:
fronteggApp.onStoreChanged(allowInterop((FronteggState state) { log(state.auth?.user?.email); })); - Add Frontegg routes as empty Container to the application router
// ... return MaterialApp( title: 'Flutter Demo', initialRoute: '/', routes: { '/': (context) => MyHomePage(title: 'Flutter Demo Home Page'), '/overview': (context) => MyHomePage(title: 'TTTT'), /** * Below Frontegg Routes */ '/account/login': (context) => Container(), '/account/logout': (context) => Container(), '/account/sign-up': (context) => Container(), '/account/activate': (context) => Container(), '/account/invitation/accept': (context) => Container(), '/account/forget-password': (context) => Container(), '/account/reset-password': (context) => Container(), '/account/social/success': (context) => Container() }, // ...
License #
This project is licensed under the terms of the MIT license.