Skip to content

isysenko/frontegg-flutter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontegg logo

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:

  1. Use setUrlStrategy(PathUrlStrategy()); to be able to work with frontegg routes
  2. 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());
      }));
    }
  3. In order to observe to changes in Frontegg store:
     fronteggApp.onStoreChanged(allowInterop((FronteggState state) {
        log(state.auth?.user?.email);
     }));
  4. 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 82.7%
  • HTML 17.3%