17$ for this? My flutter app only see first index Art-board what should I do?
late final _fileLoader = FileLoader.fromAsset(
"assets/rive/vernak.riv",
riveFactory: Factory.rive,
);
Future<void> _inspectFile() async {
try {
final file = await File.asset("assets/rive/vernak.riv", riveFactory: Factory.rive);
if (file == null) {
debugPrint('INSPECT: File.asset returned NULL');
return;
}
debugPrint('INSPECT: File loaded successfully');
for (int i = 0; i < 10; i++) {
final ab = file.artboardAt(i);
if (ab != null) {
debugPrint('INSPECT: Artboard $i: "${ab.name}"');
} else {
debugPrint('INSPECT: No more artboards at index $i');
break;
}
}
file.dispose();
} catch (e) {
debugPrint('INSPECT: Error: $e');
}
}
_______
I/flutter ( 9168): INSPECT: File loaded successfully
I/flutter ( 9168): INSPECT: Artboard 0: "Scanner"
I/flutter ( 9168): INSPECT: No more artboards at index 1
I/flutter ( 9168): Rive Loading Failed: RiveArtboardException: Artboard with name "Splash" not found.
I/flutter ( 9168): #0 RiveWidgetController._createArtboard (package:rive/src/painters/widget_controller.dart:53:7)
I/flutter ( 9168): #1 new RiveWidgetController (package:rive/src/painters/widget_controller.dart:32:16)
I/flutter ( 9168): #2 _RiveWidgetBuilderState._setup (package:rive/src/widgets/rive_builder.dart:108:13)
I/flutter ( 9168): <asynchronous suspension>
I/flutter ( 9168): Rive Current State: RiveFailed
D/FlutterJNI( 9168): Sending viewport metrics to the engine. child: RiveWidgetBuilder(
fileLoader: _fileLoader,
artboardSelector: ArtboardSelector.byName('Splash'),
onLoaded: (controller) {
debugPrint('--- Rive Discovery Start ---');
for (int i = 0; i < 20; i++) {
try {
final ab = controller.file.artboardAt(i);
if (ab != null) {
debugPrint('Artboard at index $i: "${ab.name}"');
for (int j = 0; j < 10; j++) {
try {
final sm = ab.stateMachineAt(j);
if (sm != null) {
debugPrint(' - State Machine at index $j: "${sm.name}"');
}
} catch (_) {}
}
}
} catch (e) {
debugPrint('Error at index $i: $e');
}
}
debugPrint('--- Rive Discovery End ---');
},
onFailed: (error, stackTrace) {
debugPrint('Rive Loading Failed: $error');
debugPrintStack(stackTrace: stackTrace);
},
builder: (context, state) {
debugPrint('Rive Current State: ${state.runtimeType}');
return switch (state) {
RiveLoading() => const Center(
child: CircularProgressIndicator(color: Colors.green),
),
RiveFailed() => Center(
child: Text(
'Failed to load Rive:\n${state.error}',
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.red),
),
),
RiveLoaded() => Column(
children: [
Expanded(
child: RiveWidget(
controller: state.controller,
fit: Fit.contain,
),
),
const Divider(color: Colors.white24),
Padding(
padding: const EdgeInsets.all(8.0),
child: Builder(
builder: (context) {
final List<String> names = [];
for (int i = 0; i < 10; i++) {
try {
final ab =
state.controller.file.artboardAt(i);
if (ab != null) {
names.add(ab.name);
} else {
break;
}
} catch (_) {
break;
}
}
return Text(
'Available Artboards: ${names.join(", ")}',
style: const TextStyle(
color: Colors.greenAccent, fontSize: 12),
);
},
),
),
],
),
};
},
),
Btw when I delete one art-board in rive app - then export again … I see another one in the order… but only one at the time.
Any idea?