import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:rownd_flutter_plugin/rownd.dart';
import 'package:rownd_flutter_plugin/rownd_platform_interface.dart';
import 'package:rownd_flutter_plugin/state/global_state.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final rowndPlugin = RowndPlugin(); // Initialize the Rownd plugin
@override
void initState() {
super.initState();
rowndPlugin.configure(RowndConfig(appKey: 'YOUR_APP_KEY'));// Configure the Rownd plugin with your app key
}
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => RowndCubit(rowndPlugin), // Create a RowndCubit with the Rownd plugin
child: MaterialApp(
title: 'Example App',
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.green),
),
home: BlocBuilder<RowndCubit, AuthState>(
builder: (context, state) {
// Use the RowndCubit to build the UI based on the current authentication state
if (state == AuthState.authenticated) {
return const MyHomePage();
} else {
return const LoginPage();
}
},
),
routes: {
'/home': (context) => const MyHomePage(),
},
),
);
}
}