Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void main() {
environmentId: '0322a696-4207-48c6-9ed4-ffb0aa896090',
appLogoUrl: 'https://demo.dynamic.xyz/favicon-32x32.png',
appName: 'Dynamic Demo',
appOrigin: 'https://demo.dynamic.xyz',
redirectUrl: "flutterdemo://",
),
);
Expand Down
30 changes: 19 additions & 11 deletions lib/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ class HomeView extends StatelessWidget {

return Column(
children: wallets
.map(
(wallet) => _buildWalletCard(context, wallet),
)
.map((wallet) => WalletCard(wallet: wallet))
.toList(),
);
},
Expand Down Expand Up @@ -173,8 +171,18 @@ class HomeView extends StatelessWidget {
],
);
}
}

class WalletCard extends StatelessWidget {
final BaseWallet wallet;

const WalletCard({super.key, required this.wallet});

@override
Widget build(BuildContext context) {
final isAuthenticated = wallet.isAuthenticated ?? false;
final additionalAddresses = wallet.additionalAddresses ?? const [];

Widget _buildWalletCard(BuildContext context, BaseWallet wallet) {
return Container(
margin: const EdgeInsets.only(bottom: 12),
padding: const EdgeInsets.all(12),
Expand Down Expand Up @@ -207,7 +215,7 @@ class HomeView extends StatelessWidget {
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.1),
color: Colors.blue.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
),
child: Text(
Expand Down Expand Up @@ -245,25 +253,25 @@ class HomeView extends StatelessWidget {
Row(
children: [
Icon(
wallet.isAuthenticated ? Icons.verified : Icons.warning,
color: wallet.isAuthenticated ? Colors.green : Colors.orange,
isAuthenticated ? Icons.verified : Icons.warning,
color: isAuthenticated ? Colors.green : Colors.orange,
size: 16,
),
const SizedBox(width: 4),
Text(
wallet.isAuthenticated ? 'Authenticated' : 'Not Authenticated',
isAuthenticated ? 'Authenticated' : 'Not Authenticated',
style: TextStyle(
color: wallet.isAuthenticated ? Colors.green : Colors.orange,
color: isAuthenticated ? Colors.green : Colors.orange,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
],
),
if (wallet.additionalAddresses.isNotEmpty) ...[
if (additionalAddresses.isNotEmpty) ...[
const SizedBox(height: 8),
Text(
'Additional Addresses: ${wallet.additionalAddresses.length}',
'Additional Addresses: ${additionalAddresses.length}',
style: const TextStyle(
color: Colors.grey,
fontSize: 12,
Expand Down
30 changes: 21 additions & 9 deletions lib/views/wallet_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,23 @@ class _WalletViewState extends State<WalletView> {
});
try {
final bal = await DynamicSDK.instance.wallets.getBalance(wallet: wallet);
if (!mounted) return;

setState(() {
_balance = bal;
});
} catch (e) {
if (!mounted) return;

setState(() {
_error = e.toString();
});
} finally {
if (!mounted) return;
setState(() {
_loadingBalance = false;
});
if (mounted) {
setState(() {
_loadingBalance = false;
});
}
}
}

Expand Down Expand Up @@ -201,6 +206,8 @@ class _WalletViewState extends State<WalletView> {
final transactionHash = await DynamicSDK.instance.web3dart
.sendTransaction(transaction: transaction, wallet: wallet);

if (!mounted) return;

setState(() {
_lastTxHash = transactionHash;
});
Expand All @@ -209,17 +216,20 @@ class _WalletViewState extends State<WalletView> {
const SnackBar(content: Text('Mint transaction submitted')),
);
} catch (e) {
if (!mounted) return;

setState(() {
_error = e.toString();
});
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('Mint failed: $e')));
} finally {
if (!mounted) return;
setState(() {
_busy = false;
});
if (mounted) {
setState(() {
_busy = false;
});
}
}
}

Expand Down Expand Up @@ -413,7 +423,7 @@ class _WalletHeader extends StatelessWidget {
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.1),
color: Colors.blue.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
),
child: Text(
Expand All @@ -430,6 +440,8 @@ class _WalletHeader extends StatelessWidget {
tooltip: 'Copy address',
onPressed: () async {
await Clipboard.setData(ClipboardData(text: wallet.address));
if (!context.mounted) return;

ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Address copied to clipboard'),
Expand Down
16 changes: 14 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,30 @@ import FlutterMacOS
import Foundation

import desktop_webview_window
import flutter_secure_storage_macos
import device_info_plus
import file_picker
import flutter_secure_storage_darwin
import flutter_web_auth_2
import package_info_plus
import passkeys_darwin
import path_provider_foundation
import share_plus
import ua_client_hints
import url_launcher_macos
import webview_flutter_wkwebview
import window_to_front

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DesktopWebviewWindowPlugin.register(with: registry.registrar(forPlugin: "DesktopWebviewWindowPlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
FlutterSecureStorageDarwinPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageDarwinPlugin"))
FlutterWebAuth2Plugin.register(with: registry.registrar(forPlugin: "FlutterWebAuth2Plugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PasskeysPlugin.register(with: registry.registrar(forPlugin: "PasskeysPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
UAClientHintsPlugin.register(with: registry.registrar(forPlugin: "UAClientHintsPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
WindowToFrontPlugin.register(with: registry.registrar(forPlugin: "WindowToFrontPlugin"))
Expand Down
Loading