FlutterFX Widgets
repository·main·Indexed 20 days ago
https://github.com/flutterfx/flutterfx_widgetsA library of reusable, animated visual effects for Flutter applications. Includes packages such as flutterfx_blur_fade for blur-to-sharp and fade-in transitions, flutterfx_bottom_sheet for animated bottom sheets with scale-and-slide entrances, flutterfx_orbit_blur for counter-rotating orbiting icons with frosted-glass effects, and flutterfx_scratch_to_reveal.
What's inside flutterfx_widgets
- FlutterFX is a collection of animated effects built with Flutter. Each effect is designed to serve as a building block that can be integrated into your own Flutter projects. The library provides various animated components and visual effects to enhance user interfaces.
Implement reactive configuration with OrbitConfig
mainThe
OrbitConfigclass is aChangeNotifier. You can use it with anAnimatedBuilderto allow runtime updates to the orbit's direction, duration, or path visibility without manual state management.final config = OrbitConfig(reverse: false, duration: 6.0); AnimatedBuilder( animation: config, builder: (context, _) => OrbitingIcons( reverse: config.reverse, duration: config.duration, showPaths: config.showPaths, ), ) // Mutating the config triggers a rebuild config.duration = 4.0; config.reverse = !config.reverse;How BlurFade animation works
mainThe animation uses
Curves.easeOutacross two overlapping phases to create a seamless transition:- Opacity Phase (0% - 60% of duration): Fades the widget from 0 to 1.
- Blur Phase (40% - 100% of duration): Transitions the blur sigma from 10 to 0.
Visibility Logic
isVisible: null(default): The animation plays forward automatically when the widget is first built.isVisible: true: The animation plays forward.isVisible: false: The animation reverses (fades out while increasing blur).
How ScratchToReveal works
mainThe widget operates using the following mechanism:
- A gradient image is rendered onto an offscreen canvas using the provided
gradientColors. - A
CustomPainterdraws that image on top of thechildwidget, usingBlendMode.clearto erase the path as the user performs the scratch gesture. - Once the bounding box of the scratch path covers the specified
minScratchPercentageof the total area, a scale + wiggle animation plays and theonCompletecallback is triggered.
- A gradient image is rendered onto an offscreen canvas using the provided
Quick Start with FlutterFX
mainTo get started with FlutterFX locally, follow these steps:
- Clone the repository to your local machine.
- Run
flutter pub getin the project root to install dependencies. - Open the project in your preferred IDE (e.g., VS Code, Android Studio).
- Run the application on a connected device or simulator.
flutter pub getCustomize iOS Launch Screen Assets
mainTo change the launch screen image for the iOS version of the example app, you can use one of two methods:
- Direct File Replacement: Replace the existing image files located in the
packages/flutterfx_blur_fade/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/directory with your own assets. - Xcode Interface:
- Open the iOS workspace using the command:
open ios/Runner.xcworkspace. - In the Xcode Project Navigator, navigate to
Runner/Assets.xcassets. - Drag and drop your desired images into the asset catalog.
- Open the iOS workspace using the command:
open ios/Runner.xcworkspace- Direct File Replacement: Replace the existing image files located in the
Create a new FlutterFX widget package
mainFollow these steps to initialize a new widget package within the
packagesdirectory using the standard FlutterFX structure. ReplaceWIDGET_NAMEwith your desired widget name.- Initialize directory structure: Create the necessary folders for source code, examples, and screenshots.
- Use
blur_fadeas a template: Copy the configuration and boilerplate files from the existingflutterfx_blur_fadepackage to ensure consistency in linting, licensing, and structure. - Update configuration: Ensure
pubspec.yamland library exports reflect the new name. - Add assets: Copy your showcase GIF into the
screenshots/directory. - Generate platform support: Run
flutter create .inside the example directory to ensure all platforms are supported. - Test and Publish: Run the widget locally and use
dart pub publishto release it.
# Step 1: Create Package cd packages mkdir -p flutterfx_WIDGET_NAME/lib/src mkdir -p flutterfx_WIDGET_NAME/example/lib mkdir -p flutterfx_WIDGET_NAME/screenshots # Step 2: Copy Files from blur_fade as Template cp flutterfx_blur_fade/pubspec.yaml flutterfx_WIDGET_NAME/ cp flutterfx_blur_fade/README.md flutterfx_WIDGET_NAME/ cp flutterfx_blur_fade/CHANGELOG.md flutterfx_WIDGET_NAME/ cp flutterfx_blur_fade/LICENSE flutterfx_WIDGET_NAME/ cp flutterfx_blur_fade/analysis_options.yaml flutterfx_WIDGET_NAME/ cp flutterfx_blur_fade/.gitignore flutterfx_WIDGET_NAME/ cp flutterfx_blur_fade/lib/flutterfx_blur_fade.dart flutterfx_WIDGET_NAME/lib/flutterfx_WIDGET_NAME.dart cp -r flutterfx_blur_fade/example/lib flutterfx_WIDGET_NAME/example/ cp flutterfx_blur_fade/example/pubspec.yaml flutterfx_WIDGET_NAME/example/ # Step 4: Add Screenshot cp ../external_asset/showcase_WIDGET_NAME.gif screenshots/WIDGET_NAME_demo.gif # Step 5: Generate Example Platforms cd flutterfx_WIDGET_NAME/example flutter create . # Step 6: Test flutter run # Step 7: Publish cd .. dart pub publish --dry-run dart pub publishCustomize the iOS launch screen assets
mainTo change the image displayed during the app's launch on iOS, you can either replace the image files directly in the
ios/Runner/Assets.xcassets/LaunchImage.imageset/directory or use Xcode for a more visual approach.Method 1: Direct File Replacement
Replace the existing image files within the
LaunchImage.imagesetdirectory with your own assets.Update files for a new widget package
mainWhen creating a new widget package from the
blur_fadetemplate, you must update the following files to replaceblur_fadeorWIDGET_NAMEwith your specific widget's identity:File Required Changes pubspec.yamlReplace blur_fadewithWIDGET_NAMEand update the description.README.mdUpdate the Title, description, GIF link, and usage examples. lib/flutterfx_WIDGET_NAME.dartUpdate the library name and the exported files. lib/src/Add your widget implementation code (ensure no fx_imports are used).example/pubspec.yamlReplace blur_fadewithWIDGET_NAME.example/lib/main.dartUpdate the demo code to use your new widget. Install the flutterfx_scratch_to_reveal package
mainTo use the ScratchToReveal widget in your Flutter project, install the package via the terminal or by manually adding it to your
pubspec.yamlfile.flutter pub add flutterfx_scratch_to_revealCustomise FxBottomSheet style with presets and copyWith
mainYou can style the bottom sheet using built-in presets or by fine-tuning an existing style using
copyWith().Presets:
FxBottomSheetStyle.light(): The default light theme.FxBottomSheetStyle.dark(): A dark theme preset.
Fine-tuning: Use
.copyWith()to override specific visual properties liketopBorderRadius,mainContentScale, ormainContentSlide.// Using presets FxBottomSheet(style: FxBottomSheetStyle.light(), ...) FxBottomSheet(style: FxBottomSheetStyle.dark(), ...) // Fine-tuning with copyWith FxBottomSheet( style: FxBottomSheetStyle.dark().copyWith( topBorderRadius: 28, mainContentScale: 0.90, // less dramatic scale mainContentSlide: 16, // less upward slide ), maxHeight: 0.75, // sheet takes 75% of screen height ... )Install flutterfx_bottom_sheet
mainAdd
flutterfx_bottom_sheetto yourpubspec.yamldependencies to use the animated bottom sheet widget.dependencies: flutterfx_bottom_sheet: ^1.0.0