dart_node_react_native library
React Native bindings for Dart
The return value of useReducer.
StateHook<T>
The return value of useState.
StateHookJS
State hook for JS interop types (JSString, JSObject, etc).
StateHookJSArray<T extends JSAny>
State hook for lists of JS objects.
TestNode
A node in the test render tree representing a React Native component.
TestRenderResult
Result of rendering a component for testing.
AppRegistry for registering the root component
NavigationProp
Navigation prop type (passed to screen components)
NpmComponentElement
Extension type for npm component elements
PaperButton
Typed element for Paper Button - zero-cost wrapper
PaperCard
Typed element for Paper Card - zero-cost wrapper
PaperFAB
Typed element for Paper FAB - zero-cost wrapper
PaperTextInput
Typed element for Paper TextInput - zero-cost wrapper
ReactNative
React Native core - accessed via require('react-native')
RNActivityIndicatorElement
ActivityIndicator component type
RNButtonElement
Button component type
RNFlatListElement
FlatList component type
RNImageElement
Image component type
RNSafeAreaViewElement
SafeAreaView component type
RNScrollViewElement
ScrollView component type
RNSwitchElement
Switch component type
RNTextElement
Text component type
RNTextInputElement
TextInput component type
RNTouchableOpacityElement
TouchableOpacity component type
RNViewElement
View component type
RouteProp
Route prop type (passed to screen components)
Get AppRegistry from react-native
no setter
reactNative
→ ReactNative
The global React Native module instance.
no setter
ActivityIndicator component
clearNpmModuleCache()
→ void
Clear the module cache.
createElement(JSAny type, [JSObject? props, JSAny? children])
→ ReactElement
Create a React element (convenience wrapper).
createElementWithChildren(JSAny type, JSObject? props, List<JSAny> children)
→ ReactElement
Create a React element with multiple children using spread
createFunctionalComponent(ReactElement render(JSObject props))
→ JSFunction
Create a functional component - returns the component function itself.
createProps(Map<String, dynamic> props)
→ JSObject
Create props object from a Map (with function conversion)
Extract ScreenProps from JSObject props passed to screen components.
flatList({required JSArray<JSAny?> data, required JSFunction renderItem, Map<String, dynamic>? style, Map<String, dynamic>? props})
→ RNFlatListElement
FlatList component
functionalComponent(String name, ReactElement render(JSObject props))
→ ReactElement
Create a React element with an inline functional component.
getComponentFromModule(JSObject module, String componentPath)
→ Result<JSAny, String>
Get a component from a loaded module.
isModuleCached(String packageName)
→ bool
Check if a module is cached.
loadNpmModule(String packageName)
→ Result<JSObject, String>
Load an npm module (with caching)
npmComponent(String packageName, String componentPath, {Map<String, dynamic>? props, List<ReactElement>? children, JSAny? child})
→ NpmComponentElement
Create a React element from any npm package's component.
npmComponentSafe(String packageName, String componentPath, {Map<String, dynamic>? props, List<ReactElement>? children, JSAny? child})
→ Result<NpmComponentElement, String>
Safe version of npmComponent that returns a Result instead of throwing.
npmFactory<T extends JSAny>(String packageName, String functionPath)
→ Result<T, String>
Call a factory function from an npm module.
paperButton({PaperButtonProps? props, void onPress()?, String? label})
→ PaperButton
Create a Paper Button with full type safety.
paperCard({PaperCardProps? props, void onPress()?, List<ReactElement>? children})
→ PaperCard
Create a Paper Card with full type safety.
paperFAB({PaperFABProps? props, void onPress()?})
→ PaperFAB
Create a Paper FAB with full type safety.
paperTextInput({PaperTextInputProps? props, void onChangeText(String)?, String? value})
→ PaperTextInput
Create a Paper TextInput with full type safety.
registerApp(String appName, JSFunction component)
→ void
Register the main app component
renderForTest(ReactElement element)
→ TestRenderResult
Render a React element for testing.
rnButton({required String title, void onPress()?, String? color, bool? disabled, Map<String, dynamic>? props})
→ RNButtonElement
Button component
rnElement(String componentName, {Map<String, dynamic>? props, List<ReactElement>? children, JSAny? child})
→ ReactElement
Create a React Native element
Note: child accepts JSAny? to support both ReactElement and text strings
rnImage({required Map<String, dynamic> source, Map<String, dynamic>? style, String? resizeMode, Map<String, dynamic>? props})
→ RNImageElement
Image component
rnSwitch({bool? value, void onValueChange(bool)?, String? trackColor, String? thumbColor, Map<String, dynamic>? props})
→ RNSwitchElement
Switch component
safeAreaView({Map<String, dynamic>? style, Map<String, dynamic>? props, List<ReactElement>? children, JSAny? child})
→ RNSafeAreaViewElement
SafeAreaView component
scrollView({Map<String, dynamic>? style, Map<String, dynamic>? contentContainerStyle, Map<String, dynamic>? props, List<ReactElement>? children, JSAny? child})
→ RNScrollViewElement
ScrollView component
setupTestEnvironment()
→ void
Install mock React Native components for testing
text(String content, {Map<String, dynamic>? style, Map<String, dynamic>? props, void onPress()?})
→ RNTextElement
Text component
textInput({String? value, String? placeholder, bool? secureTextEntry, void onChangeText(String)?, Map<String, dynamic>? style, Map<String, dynamic>? props})
→ RNTextInputElement
TextInput component
touchableOpacity({void onPress()?, Map<String, dynamic>? style, Map<String, dynamic>? props, List<ReactElement>? children, JSAny? child})
→ RNTouchableOpacityElement
TouchableOpacity component
useCallback(Function callback, List<Object?> dependencies)
→ JSFunction
Returns a memoized version of callback that only changes if one of the
dependencies has changed.
useDebugValue<T>(T value, [String format(T)?])
→ void
Displays value as a label for a custom hook in React DevTools.
useEffect(Object? sideEffect(), [List<Object?>? dependencies])
→ void
Runs sideEffect after every completed render of a function component.
useImperativeHandle<T>(Object? ref, T createHandle(), [List<Object?>? dependencies])
→ void
Customizes the ref value that is exposed to parent components when using
forwardRef2 by setting ref.current to the return value of
createHandle.
useLayoutEffect(Object? sideEffect(), [List<Object?>? dependencies])
→ void
Runs sideEffect synchronously after a function component renders, but
before the screen is updated.
useMemo<T>(T createFunction(), [List<Object?>? dependencies])
→ T
Returns a memoized version of the return value of createFunction.
userClear(TestNode input)
→ void
Clear a text input
useReducer<TState, TAction>(TState reducer(TState state, TAction action), TState initialState)
→ ReducerHook<TState, TAction>
Initializes state of a function component to initialState and creates a
dispatch method.
useReducerLazy<TState, TAction, TInit>(TState reducer(TState state, TAction action), TInit initialArg, TState init(TInit))
→ ReducerHook<TState, TAction>
Initializes state of a function component to init(initialArg) and creates
dispatch method.
useRef<T>([T? initialValue])
→ Ref<T?>
Returns an empty mutable Ref object.
useRefInit<T>(T initialValue)
→ Ref<T>
Returns a mutable Ref object with Ref.current property initialized to
initialValue.
userPress(TestNode node)
→ void
Simulate pressing a touchable element
userType(TestNode input, String text)
→ Future<void>
Simulate typing into a TextInput.
useState<T>(T initialValue)
→ StateHook<T>
Adds local state to a function component by returning a StateHook with
StateHook.value initialized to initialValue.
useStateJS(JSAny? initialValue)
→ StateHookJS
Adds local state for JS interop types to a function component.
useStateJSArray<T extends JSAny>(JSAny? initialValue)
→ StateHookJSArray<T>
Adds local state for lists of JS objects to a function component.
useStateLazy<T>(T init())
→ StateHook<T>
Adds local state to a function component by returning a StateHook with
StateHook.value initialized to the return value of init.
view({Map<String, dynamic>? style, Map<String, dynamic>? props, List<ReactElement>? children, JSAny? child, void onPress()?})
→ RNViewElement
View component - the fundamental building block
PaperButtonProps
= ({String? buttonColor, Map<String, dynamic>? contentStyle, bool? disabled, Map<String, dynamic>? labelStyle, bool? loading, String? mode, Map<String, dynamic>? style, String? textColor})
Props for Paper Button
PaperCardProps
= ({Map<String, dynamic>? contentStyle, String? mode, Map<String, dynamic>? style})
Props for Paper Card
PaperFABProps
= ({String? color, String? customColor, bool? disabled, String? icon, String? label, bool? loading, bool? small, Map<String, dynamic>? style, bool? visible})
Props for Paper FAB (Floating Action Button)
PaperTextInputProps
= ({String? activeOutlineColor, String? activeUnderlineColor, bool? disabled, bool? editable, String? label, String? mode, String? placeholder, bool? secureTextEntry, Map<String, dynamic>? style, String? textColor, String? value})
Props for Paper TextInput
ScreenProps
= ({NavigationProp navigation, RouteProp route})
Screen component props (navigation + route)
Exception thrown by testing library.