Repository: rive-app/rive-flutter

Issue #354: Flutter test breaks when using textRun
Created: 2023-11-24T17:32:39Z
Description
flutter test breaks when trying to test a widget that uses dynamic texts:
RiveAnimation.asset(
    'foo.riv',
    fit: BoxFit.contain,
    stateMachines: const ['State Machine 1'],
    onInit: (artboard) {
        final bookTraining = artboard.textRun('bookTraining');
        bookTraining.text = 'bookTraining'.i18n;
});

Any test with that widget returns:
Invalid argument(s): Failed to lookup symbol 'init': dlsym(RTLD_DEFAULT, init): symbol not found

When the exception was thrown, this was the stack:
#0      DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33:70)
#1      init (package:rive_common/src/rive_text_ffi.dart:528:15)
#2      init (package:rive_common/src/rive_text_ffi.dart)
#3      initFont (package:rive_common/src/rive_text_ffi.dart:837:3)
#4      Font.initialize (package:rive_common/rive_text.dart:469:12)
#5      RiveFile._initTextAndImport (package:rive/src/rive_file.dart:362:20)
#6      RiveFile.asset (package:rive/src/rive_file.dart:392:12)
<asynchronous suspension>

Steps To Reproduce
Steps to reproduce the behavior:
Write a test pumping the mentioned widget.
Expected behavior
Test suite should work

Duplicate issue #417: Unable to use Rive in widget tests
Created: 2024-08-28T18:26:30Z
Description
When running my widget tests those making use of rive-flutter fail with the following console output:
00:01 +0 -1: loading C:/Users/***/Desktop/open_local_ui/app/test/frontend/rive_animation_test.dart [E]
  Failed to load "C:/Users/***/Desktop/open_local_ui/app/test/frontend/rive_animation_test.dart":
  Invalid argument(s): Failed to load dynamic library 'rive_common_plugin.dll': The specified module could not be found.
   (error code: 126)
  dart:ffi                                                   new DynamicLibrary.open
  package:rive_common/src/dynamic_library_helper.dart 47:29  RiveDynamicLibraryHelper.open
  package:rive_common/src/dynamic_library_helper.dart 14:43  RiveDynamicLibraryHelper.nativeLib
  package:rive_common/src/dynamic_library_helper.dart        RiveDynamicLibraryHelper.nativeLib
  package:rive_common/src/rive_text_ffi.dart 10:59           _nativeLib
  package:rive_common/src/rive_text_ffi.dart 491:5           init
  package:rive_common/src/rive_text_ffi.dart                 init
  package:rive_common/src/rive_text_ffi.dart 808:3           initFont
  package:rive_common/rive_text.dart 461:7                   Font.initialize
  package:rive/src/rive_file.dart 392:33                     RiveFile.initialize
  test\frontend\rive_animation_test.dart 9:18                main


To run this test again: C:\tools\flutter\bin\cache\dart-sdk\bin\dart.exe test C:/Users/***/Desktop/open_local_ui/app/test/frontend/rive_animation_test.dart -p vm --plain-name "loading C:/Users/***/Desktop/open_local_ui/app/test/frontend/rive_animation_test.dart"
00:01 +0 -1: Some tests failed.
The problem seems to be related to the rive_common_plugin DLL not being found during test runs despite being correclty built and present in the build directories (both debug and release). The issue does not show up during normal flutter runs both on Linux and Windows. I'm running the latest rive release an the latest stable flutter release.
Steps To Reproduce
Steps to reproduce the behavior:

Try to write any widget unit test around Rive

Expected behavior
The test should succeed or fail without any rive-flutter related errors but rather my own errors.
Device & Versions (please complete the following information)

Device: PC
OS: Windows 11 Pro
Flutter Version:

Flutter 3.24.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 80c2e84975 (4 weeks ago) • 2024-07-30 23:06:49 +0700
Engine • revision b8800d88be
Tools • Dart 3.5.0 • DevTools 2.37.2

Closing comment (2024-09-04T09:19:47Z): We're working on resolving this with the next major version that will change how the underlying native libraries are built. Closing this issue as a duplicate of #354
More information there.