Created
July 7, 2022 17:03
-
-
Save salihgueler/e14e7e1116c979a93422a819c2f1251c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:amplify_auth_cognito/amplify_auth_cognito.dart'; | |
| import 'package:amplify_authenticator/amplify_authenticator.dart'; | |
| import 'package:amplify_flutter/amplify_flutter.dart'; | |
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(const MyApp()); | |
| } | |
| class MyApp extends StatefulWidget { | |
| const MyApp({Key? key}) : super(key: key); | |
| @override | |
| State<MyApp> createState() => _MyAppState(); | |
| } | |
| class _MyAppState extends State<MyApp> { | |
| @override | |
| void initState() { | |
| super.initState(); | |
| _configureAmplify(); | |
| } | |
| void _configureAmplify() async { | |
| try { | |
| await Amplify.addPlugin(AmplifyAuthCognito()); | |
| await Amplify.configure(amplifyconfig); | |
| print('Successfully configured'); | |
| } on Exception catch (e) { | |
| print('Error configuring Amplify: $e'); | |
| } | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return Authenticator( | |
| child: MaterialApp( | |
| builder: Authenticator.builder(), | |
| home: const Scaffold( | |
| body: Center( | |
| child: Text('You are logged in!'), | |
| ), | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment