import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; Future main() async { final prefs = await SharedPreferences.getInstance(); // Check for the uuid key in the shared preferences if (!prefs.containsKey('uuid')) { // Create an account using https://api.firewallet.au/account // and get the uuid from the response final response = await http.post( Uri.parse('https://api.firewallet.au/account'), headers: { 'Content-Type': 'application/json; charset=UTF-8', }, body: '{}', ); // Get uuid from { "userID": "..." } final uuid = jsonDecode(response.body)['userID']; // Save the uuid to the shared preferences await prefs.setString('uuid', uuid); } // Get the uuid from the shared preferences final String? uuid = prefs.getString('uuid'); runApp(MyApp(uuid: uuid ?? 'null')); } class MyApp extends StatelessWidget { const MyApp({ super.key, required this.uuid, }); final String uuid; // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Fire Wallet', theme: ThemeData( brightness: Brightness.light, /* light theme settings */ ), darkTheme: ThemeData( brightness: Brightness.dark, /* dark theme settings */ ), themeMode: ThemeMode.system, debugShowCheckedModeBanner: false, home: MyHomePage(uuid: uuid), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({ super.key, required this.uuid, }); final String uuid; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { int currentPageIndex = 0; @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); return Scaffold( bottomNavigationBar: NavigationBar( onDestinationSelected: (int index) { setState(() { currentPageIndex = index; }); }, selectedIndex: currentPageIndex, destinations: const [ NavigationDestination( selectedIcon: Icon(Icons.home), icon: Icon(Icons.home_outlined), label: 'Home', ), NavigationDestination( icon: Icon(Icons.text_format_rounded), label: 'Domains', ), NavigationDestination( icon: Icon(Icons.receipt), label: 'Transactions', ), ], ), body: [ /// Home page Card( shadowColor: Colors.transparent, margin: const EdgeInsets.all(8.0), child: SizedBox.expand( child: Center( child: Text( 'Welcome to Fire Wallet! 🚀', style: theme.textTheme.titleLarge, ), ), ), ), /// Notifications page Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Card( child: Center( child: Text( // UUID of the user 'UUID: ${widget.uuid}', ))), ], ), ), /// Messages page ListView.builder( reverse: true, itemCount: 2, itemBuilder: (BuildContext context, int index) { if (index == 0) { return Align( alignment: Alignment.centerRight, child: Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( color: theme.colorScheme.primary, borderRadius: BorderRadius.circular(8.0), ), child: Text( 'Hello', style: theme.textTheme.bodyLarge! .copyWith(color: theme.colorScheme.onPrimary), ), ), ); } return Align( alignment: Alignment.centerLeft, child: Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( color: theme.colorScheme.primary, borderRadius: BorderRadius.circular(8.0), ), child: Text( 'Hi!', style: theme.textTheme.bodyLarge! .copyWith(color: theme.colorScheme.onPrimary), ), ), ); }, ), ][currentPageIndex], ); } }