at_client_mobile 3.2.12 at_client_mobile: ^3.2.12 copied to clipboard
A Flutter extension to the at_client library which adds support for mobile, desktop and IoT devices.
import 'dart:async';
import 'package:at_client_mobile_example/src/screens/home.dart';
import 'package:at_client_mobile_example/src/screens/login.dart';
import 'package:flutter/material.dart';
import 'package:at_client_mobile/at_client_mobile.dart';
import 'package:path_provider/path_provider.dart'
show getApplicationSupportDirectory;
import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv;
Future<void> main() async {
await AtEnv.load();
runApp(const MyApp());
}
Future<AtClientPreference> loadAtClientPreference() async {
var dir = await getApplicationSupportDirectory();
return AtClientPreference()
..rootDomain = AtEnv.rootDomain
..namespace = AtEnv.appNamespace
..hiveStoragePath = dir.path
..commitLogPath = dir.path
..isLocalStoreRequired = true;
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
// * load the AtClientPreference in the background
Future<AtClientPreference> futurePreference = loadAtClientPreference();
AtClientPreference? atClientPreference;
@override
Widget build(BuildContext context) {
return MaterialApp(
// * The onboarding screen (first screen)
initialRoute: LoginScreen.id,
routes: <String, Widget Function(BuildContext)>{
LoginScreen.id: (BuildContext context) => const LoginScreen(),
HomeScreen.id: (BuildContext context) => const HomeScreen(),
},
);
}
}