Flutter library for Internet Computer Protocol (ICP) blockchain operations, designed as a provider for the flutter_nft universal NFT library.
- 🌐 ICP Blockchain Integration - Full support for Internet Computer Protocol
- 💼 Plug Wallet Integration - Seamless wallet connectivity
- 🛒 Yuku Marketplace - Trade NFTs on Yuku marketplace
- 🔌 Provider Architecture - Works with flutter_nft universal library
- 📱 Cross-platform - Works on iOS, Android, Web, and Desktop
- 🔒 Type-safe - Full type safety with Dart's type system
Add this to your package's pubspec.yaml file:
dependencies:
flutter_icp: ^1.0.0
flutter_nft: ^1.0.0 # Requiredimport 'package:flutter_nft/flutter_nft.dart';
import 'package:flutter_icp/flutter_icp.dart';
void main() async {
// Create NFT client
final nftClient = NFTClient();
// Register ICP providers
nftClient.registerNFTProvider(ICPNFTProvider());
nftClient.registerWalletProvider(PlugWalletProvider());
nftClient.registerMarketplaceProvider(YukuMarketplaceProvider());
// Initialize all providers
await nftClient.initialize();
runApp(MyApp());
}// Get wallet provider
final walletProvider = nftClient.getWalletProvider(BlockchainNetwork.icp);
// Connect to wallet
final isConnected = await walletProvider.connect();
if (isConnected) {
final address = await walletProvider.getAddress();
print('Connected to: $address');
}// Get NFT provider
final nftProvider = nftClient.getNFTProvider(BlockchainNetwork.icp);
// Get user's NFTs
final nfts = await nftProvider.getNFTsByOwner(userAddress);
print('Found ${nfts.length} NFTs');// Create NFT metadata
final metadata = NFTMetadata(
name: 'My ICP NFT',
description: 'This is my ICP NFT',
image: 'https://example.com/image.png',
attributes: {
'Color': 'Blue',
'Rarity': 'Rare',
},
);
// Mint the NFT
final transactionHash = await nftProvider.mintNFT(
toAddress: userAddress,
metadata: metadata,
contractAddress: 'your-canister-id',
);// Get marketplace provider
final marketplaceProvider = nftClient.getMarketplaceProvider(BlockchainNetwork.icp);
// Create listing
final listingId = await marketplaceProvider.createListing(
nftId: nft.tokenId,
contractAddress: nft.contractAddress,
price: 100.0,
currency: 'ICP',
sellerAddress: userAddress,
);import 'package:flutter_icp/flutter_icp.dart';
// Use mainnet (default)
ICPConfig.instance.useMainnet();
// Use testnet
ICPConfig.instance.useTestnet();
// Custom configuration
ICPConfig.instance.setNetworkConfig(ICPNetworkConfig(
name: 'Custom ICP Network',
url: 'https://custom-icp.network',
isTestnet: false,
canisterIds: {
'ledger': 'your-ledger-canister-id',
'nft': 'your-nft-canister-id',
},
));// Set custom canister IDs
ICPConfig.instance.setCanisterId('nft', 'your-nft-canister-id');
ICPConfig.instance.setCanisterId('marketplace', 'your-marketplace-canister-id');
// Set custom parameters
ICPConfig.instance.setCustomParam('apiKey', 'your-api-key');
ICPConfig.instance.setCustomParam('timeout', 30);import 'package:flutter_icp/flutter_icp.dart';
final client = ICPClient.instance;
// Initialize
await client.initialize();
// Make query calls
final result = await client.query(
canisterId: 'your-canister-id',
method: 'get_data',
args: {'param': 'value'},
);
// Make update calls
final updateResult = await client.update(
canisterId: 'your-canister-id',
method: 'update_data',
args: {'param': 'value'},
);import 'package:flutter_icp/flutter_icp.dart';
final walletService = PlugWalletService();
// Initialize
await walletService.initialize();
// Connect
final connected = await walletService.connect();
// Get balance
final balances = await walletService.getBalance();
// Send transaction
final success = await walletService.sendTransaction(
to: 'recipient-address',
amount: 1.0,
currency: 'ICP',
);
// Approve NFT transaction
final approved = await walletService.approveNFTTransaction(
nftCanisterId: 'nft-canister-id',
nftId: 'nft-token-id',
price: 100.0,
currency: 'ICP',
);import 'package:flutter_icp/flutter_icp.dart';
final yukuService = YukuService();
// Initialize
await yukuService.initialize();
// Get active listings
final listings = await yukuService.getActiveListings();
// Create listing
final success = await yukuService.createListing(
nftId: 'nft-id',
price: 100.0,
currency: 'ICP',
);
// Make offer
final offerSuccess = await yukuService.makeOffer(
nftId: 'nft-id',
amount: 90.0,
currency: 'ICP',
);The library follows a provider-based architecture that integrates with flutter_nft:
NFTClient (from flutter_nft)
├── ICPNFTProvider (ICP-specific NFT operations)
├── PlugWalletProvider (Plug Wallet integration)
└── YukuMarketplaceProvider (Yuku marketplace integration)
All providers implement the standard interfaces from flutter_nft:
NFTProvider- NFT operationsWalletProvider- Wallet connectivityMarketplaceProvider- Marketplace operations
- ✅ Mint NFTs
- ✅ Transfer NFTs
- ✅ Burn NFTs
- ✅ Approve NFT transfers
- ✅ Get NFT metadata
- ✅ Update NFT metadata
- ✅ Search NFTs
- ✅ Connect to Plug Wallet
- ✅ Get balances
- ✅ Send transactions
- ✅ Sign messages
- ✅ Approve transactions
- ✅ Get transaction history
- ✅ Create listings
- ✅ Buy NFTs
- ✅ Make offers
- ✅ Accept/reject offers
- ✅ Cancel listings
- ✅ Search listings
The library provides specific exception types:
try {
final nfts = await nftProvider.getNFTsByOwner(address);
} on ICPPrincipalInvalidException catch (e) {
// Handle invalid ICP principal
} on ICPTransactionException catch (e) {
// Handle transaction failure
} on ICPNetworkException catch (e) {
// Handle network issues
} on WalletNotConnectedException catch (e) {
// Handle wallet not connected
}Check out the example/ directory for complete examples:
- Basic NFT operations
- Wallet integration
- Marketplace trading
- Custom configuration
We welcome contributions! Please see our Contributing Guide for details.
This project is licensed under the NativeMindNONC - see the LICENSE file for details.
- flutter_nft - Universal NFT library
- Plug Wallet - ICP wallet extension
- Yuku - ICP NFT marketplace