Cannot access artboards in Flutter
I am using the latest Rive 0.14.0-dev.14 version. I have 3 artboards in my .riv file. I can only access the artboard, of which the state machine was active before exporting the .riv file. (On the top left section, inside the Rive editor, there is a play button icon and a drop-down to select the active artboard and state machine.) Other artboards are printing as null. I have 3 separate artboards in Rive editor(MountainTracker, GlassTracker, and ChakraTracker). I have rechecked the name. Hereβs the code that i am using to fetch the artboards.
Future<void> loadAssets() async { /
if (_isLoaded || _isLoading) {
debugPrint('βοΈ AssetLoader: Already loaded or loading, skipping...');
return;
}
_isLoading = true;
_error = null;
notifyListeners();
try {
debugPrint('π AssetLoader: Starting Rive file loading...');
// β
Following example pattern from databinding_artboards.dart
// Load File directly to enable artboard switching
// Note: Using Factory.flutter as in the example. Factory.rive is generally recommended.
final file = await rive.File.asset(
'assets/rive/trackers.riv',
riveFactory: rive.Factory.flutter,
);
// --- NEW LOGGING BLOCK ---
if (file != null) {
debugPrint('--- ARTBOARD VERIFICATION START ---');
// 1. Log the total number of artboards found in the file
debugPrint('π Total data enum Found: ${file.enums.length}');
// // 2. Log the name of EVERY artboard the file contains
// for (var artboard in file) {
// debugPrint('Artboard in file list: "${artboard.name}"');
// }
debugPrint('-----------------------------------');
}
// --- END NEW LOGGING BLOCK ---
// Test artboard retrieval using case-sensitive names
final tracker1 = file?.artboard('MountainTracker');
final tracker2 = file?.artboard('GlassTracker');
final tracker3 = file?.artboard('ChakraTracker');
// Note: Re-checked artboard names from previous conversation for consistency
print('trackerLog MountainTracker: $tracker1');
print('trackerLog GlassTracker: $tracker2');
print('trackerLog ChakraTracker: $tracker3');
_cachedFile = file;
_isLoaded = true;
debugPrint('β
AssetLoader: Rive File loaded and cached successfully');
} catch (e, stackTrace) {
_error = 'Failed to load Rive file: $e';
debugPrint('β AssetLoader: Critical error loading Rive file: $e');
debugPrint('β AssetLoader: Stack trace: $stackTrace');
_cachedFile = null;
} finally {
_isLoading = false;
notifyListeners();
}
}The printing output is
I/flutter ( 4666): trackerLog MountainTracker: Instance of 'FFIRiveArtboard'
I/flutter ( 4666): trackerLog GlassTracker: null
I/flutter ( 4666): trackerLog ChakraTracker: null