diff --git a/.fvmrc b/.fvmrc new file mode 100644 index 0000000..73f20c4 --- /dev/null +++ b/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "3.32.7" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9be145f..1da0123 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ .dart_tool/ .packages build/ + +# FVM Version Cache +.fvm/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c35aa5f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,19 @@ +{ + "dart.flutterSdkPath": ".fvm/versions/3.32.7", + "workbench.colorCustomizations": { + "titleBar.activeBackground": "#e8885f", + "titleBar.activeForeground": "#000000", + "titleBar.inactiveBackground": "#e8885f", + "titleBar.inactiveForeground": "#000000", + "titleBar.border": "#e8885f", + "activityBar.background": "#e8885f", + "activityBar.foreground": "#000000", + "statusBar.background": "#e8885f", + "statusBar.foreground": "#000000", + "statusBar.debuggingBackground": "#e8885f", + "statusBar.debuggingForeground": "#000000", + "tab.activeBorder": "#e8885f", + "iLoveWorkSpaceColors": true, + "iLoveWorkSpaceRandom": false + } +} diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..e14ea9f --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,26 @@ +# Agent Guidelines for Wave Linear Progress Indicator + +## Build/Test/Lint Commands +- **Test all**: `flutter test` +- **Test single file**: `flutter test test/wave_linear_progress_indicator_test.dart` +- **Lint**: `flutter analyze` +- **Format**: `dart format .` +- **Get dependencies**: `flutter pub get` + +## Code Style Guidelines +- **Language**: Dart/Flutter package following flutter_lints rules +- **Imports**: Use relative imports for local files, package imports for external dependencies +- **Naming**: camelCase for variables/methods, PascalCase for classes, snake_case for files +- **Types**: Use explicit types for public APIs, prefer `final` over `var` +- **Documentation**: Use /// for public APIs, include parameter descriptions +- **Error handling**: Use proper exception types, avoid silent failures +- **File structure**: Export public APIs through main library file, keep implementation in src/ +- **Animation**: Use AnimationController with TickerProviderStateMixin for custom animations +- **Widget structure**: Extend appropriate base classes (ProgressIndicator), use const constructors +- **Comments**: Include file headers with creation date and author when creating new files + +## Project Structure +- Main library: `lib/wave_linear_progress_indicator.dart` (exports only) +- Implementation: `lib/src/` directory +- Tests: `test/` directory +- Uses flutter_lints for code analysis \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index d2f5d63..3a57709 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -25,6 +25,9 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), + builder: (context, child) { + return Directionality(textDirection: TextDirection.rtl, child: child!); + }, home: const MyHomePage(title: 'WaveLinearProgressIndicator Demo Home Page'), ); @@ -32,10 +35,10 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - const MyHomePage({Key? key, required this.title}) : super(key: key); - final String title; + const MyHomePage({Key? key, required this.title}) : super(key: key); + @override State createState() => _MyHomePageState(); } @@ -114,6 +117,15 @@ class _MyHomePageState extends State { ); } + void _decrease() { + final delta = Random().nextDouble(); + double newValue = _progress - delta; + newValue = newValue.clamp(0, 1); + setState(() { + _progress = newValue; + }); + } + Stream _getDownloadProgress() async* { final values = [ 0, @@ -143,13 +155,4 @@ class _MyHomePageState extends State { _progress = newValue; }); } - - void _decrease() { - final delta = Random().nextDouble(); - double newValue = _progress - delta; - newValue = newValue.clamp(0, 1); - setState(() { - _progress = newValue; - }); - } } diff --git a/example/pubspec.lock b/example/pubspec.lock index 3d0e9ff..923aee6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,58 +5,58 @@ packages: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.13.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" characters: dependency: transitive description: name: characters - url: "https://pub.flutter-io.cn" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.3.1" + version: "1.4.0" clock: dependency: transitive description: name: clock - url: "https://pub.flutter-io.cn" + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.2" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.19.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.flutter-io.cn" + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.0.8" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.flutter-io.cn" + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.3" flutter: dependency: "direct main" description: flutter @@ -66,7 +66,8 @@ packages: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.flutter-io.cn" + sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 + url: "https://pub.dev" source: hosted version: "1.0.4" flutter_test: @@ -74,102 +75,139 @@ packages: description: flutter source: sdk version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + url: "https://pub.dev" + source: hosted + version: "10.0.9" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + url: "https://pub.dev" + source: hosted + version: "3.0.9" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: name: lints - url: "https://pub.flutter-io.cn" + sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c + url: "https://pub.dev" source: hosted version: "1.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.12.17" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.flutter-io.cn" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "0.11.1" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.16.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.1" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.2" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + url: "https://pub.dev" source: hosted - version: "0.4.8" - typed_data: + version: "0.7.4" + vector_math: dependency: transitive description: - name: typed_data - url: "https://pub.flutter-io.cn" + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "1.3.0" - vector_math: + version: "2.1.4" + vm_service: dependency: transitive description: - name: vector_math - url: "https://pub.flutter-io.cn" + name: vm_service + sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "15.0.0" wave_linear_progress_indicator: dependency: "direct main" description: @@ -178,5 +216,5 @@ packages: source: path version: "0.1.0" sdks: - dart: ">=2.16.2 <3.0.0" - flutter: ">=1.17.0" + dart: ">=3.7.0-0 <4.0.0" + flutter: ">=3.32.0" diff --git a/example/windows/flutter/generated_plugins.cmake b/example/windows/flutter/generated_plugins.cmake index 4d10c25..b93c4c3 100644 --- a/example/windows/flutter/generated_plugins.cmake +++ b/example/windows/flutter/generated_plugins.cmake @@ -5,6 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/lib/src/progress_label.dart b/lib/src/progress_label.dart index 644a622..1526547 100644 --- a/lib/src/progress_label.dart +++ b/lib/src/progress_label.dart @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; class ProgressLabel extends StatelessWidget { const ProgressLabel({ - Key? key, + super.key, required this.progress, this.decoration, - }) : super(key: key); + }); final double progress; final Decoration? decoration; diff --git a/lib/src/wave_indicator_painter.dart b/lib/src/wave_indicator_painter.dart index 69c48c0..de596f1 100644 --- a/lib/src/wave_indicator_painter.dart +++ b/lib/src/wave_indicator_painter.dart @@ -20,6 +20,7 @@ class WaveIndicatorPainter extends CustomPainter { required this.waveBackgroundColor, required this.waveStep, required this.waveColor, + required this.isRTL, }) : super(repaint: Listenable.merge([repaint, progressAnimation])); final Animation repaint; @@ -30,7 +31,7 @@ class WaveIndicatorPainter extends CustomPainter { final Color waveBackgroundColor; final double waveStep; final Color waveColor; - + final bool isRTL; final Paint _paint = Paint(); @override @@ -51,25 +52,32 @@ class WaveIndicatorPainter extends CustomPainter { void _drawBG(Canvas canvas, Size size) { final progress = progressAnimation.value; - final left = size.width * progress; _paint ..color = backgroundColor ..style = PaintingStyle.fill; - final rect = Offset(left, 0) & Size(size.width - left, size.height); + + final Rect rect; + if (isRTL) { + // RTL: Fill from left side (unfilled area) + final width = size.width * (1 - progress); + rect = Offset(0, 0) & Size(width, size.height); + } else { + // LTR: Fill from right side (unfilled area) + final left = size.width * progress; + rect = Offset(left, 0) & Size(size.width - left, size.height); + } + canvas.drawRect(rect, _paint); } - void _drawWaves(Canvas canvas, Size size) { canvas.save(); - // final progress = progressAnimation.value; - // final width = size.width * progress; _paint ..color = waveBackgroundColor ..style = PaintingStyle.fill; canvas.drawRect(Offset.zero & size, _paint); canvas.clipRect(Offset.zero & size); - const angle = 20; + final angle = isRTL ? -20.0 : 20.0; // Reverse wave angle for RTL _paint ..color = waveColor ..style = PaintingStyle.fill; @@ -78,7 +86,9 @@ class WaveIndicatorPainter extends CustomPainter { final height = size.height * 2.0; final realWidth = (waveWidth + waveStep) * count; - final offset = -realWidth * repaint.value; + final offset = isRTL + ? realWidth * repaint.value // Reverse wave direction for RTL + : -realWidth * repaint.value; canvas.translate(offset, 0); for (int i = 0; i < count * 2; i++) { @@ -96,7 +106,6 @@ class WaveIndicatorPainter extends CustomPainter { } canvas.restore(); } - @override bool shouldRepaint(covariant WaveIndicatorPainter oldDelegate) => oldDelegate.backgroundColor != backgroundColor || @@ -106,5 +115,5 @@ class WaveIndicatorPainter extends CustomPainter { oldDelegate.waveWidth != waveWidth || oldDelegate.waveStep != waveStep || oldDelegate.waveBackgroundColor != waveBackgroundColor || - oldDelegate.waveColor != waveColor; -} + oldDelegate.waveColor != waveColor || + oldDelegate.isRTL != isRTL;} diff --git a/lib/src/wave_linear_progress_indicator.dart b/lib/src/wave_linear_progress_indicator.dart index 34bfb14..9412a98 100644 --- a/lib/src/wave_linear_progress_indicator.dart +++ b/lib/src/wave_linear_progress_indicator.dart @@ -12,26 +12,6 @@ import 'package:wave_linear_progress_indicator/src/progress_label.dart'; import 'wave_indicator_painter.dart'; class WaveLinearProgressIndicator extends ProgressIndicator { - const WaveLinearProgressIndicator({ - Key? key, - required double value, - Color? backgroundColor = const Color(0xFFECF4F2), - Color? color, - this.minHeight, - this.borderRadius = 18, - this.waveWidth = 10, - this.waveColor = const Color(0x21FFFFFF), - this.waveBackgroundColor = const Color(0xFF71E4D6), - this.waveStep = 8, - this.labelDecoration, - this.enableBounceAnimation = false, - }) : super( - key: key, - value: value, - backgroundColor: backgroundColor, - color: color, - ); - /// The minimum height of the line used to draw the linear indicator. final double? minHeight; @@ -56,6 +36,21 @@ class WaveLinearProgressIndicator extends ProgressIndicator { /// Whether to turn on the bouncing animation effect final bool enableBounceAnimation; + const WaveLinearProgressIndicator({ + super.key, + required double super.value, + super.backgroundColor = const Color(0xFFECF4F2), + super.color, + this.minHeight, + this.borderRadius = 18, + this.waveWidth = 10, + this.waveColor = const Color(0x21FFFFFF), + this.waveBackgroundColor = const Color(0xFF71E4D6), + this.waveStep = 8, + this.labelDecoration, + this.enableBounceAnimation = false, + }); + @override State createState() => _WaveLinearProgressIndicatorState(); } @@ -68,6 +63,16 @@ class _WaveLinearProgressIndicatorState final GlobalKey _progressLabelKey = GlobalKey(); + Color get _backgroundColor { + final Color trackColor = widget.backgroundColor ?? + _indicatorTheme.linearTrackColor ?? + Theme.of(context).colorScheme.surface; + return trackColor; + } + + ProgressIndicatorThemeData get _indicatorTheme => + ProgressIndicatorTheme.of(context); + Decoration get _labelDecoration { if (widget.labelDecoration != null) { return widget.labelDecoration!; @@ -89,32 +94,50 @@ class _WaveLinearProgressIndicatorState ); } - Color get _backgroundColor { - final Color trackColor = widget.backgroundColor ?? - _indicatorTheme.linearTrackColor ?? - Theme.of(context).colorScheme.background; - return trackColor; - } - double get _minHeight => widget.minHeight ?? _indicatorTheme.linearMinHeight ?? 9; double get _progressLabelHeight => _minHeight + 4.5 * 2; - ProgressIndicatorThemeData get _indicatorTheme => - ProgressIndicatorTheme.of(context); - @override - void initState() { - _waveController = AnimationController( - vsync: this, duration: const Duration(milliseconds: 5000)); - _waveController.repeat(); - _progressController = AnimationController( - vsync: this, duration: const Duration(milliseconds: 500)); - - _progressAnimation = - Tween(begin: widget.value).animate(_progressController); - super.initState(); + Widget build(BuildContext context) { + return Container( + constraints: BoxConstraints( + minWidth: double.infinity, + minHeight: _progressLabelHeight, + ), + child: LayoutBuilder(builder: (context, constraints) { + // print('=======layout===$constraints'); + return Stack( + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Center( + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: _minHeight, + minWidth: double.infinity, + ), + child: CustomPaint( + painter: WaveIndicatorPainter( + repaint: _waveController, + progressAnimation: _progressAnimation, + backgroundColor: _backgroundColor, + borderRadius: widget.borderRadius, + waveWidth: widget.waveWidth, + waveBackgroundColor: widget.waveBackgroundColor, + waveStep: widget.waveStep, + waveColor: widget.waveColor, + isRTL: Directionality.of(context) == TextDirection.rtl, + ), + ), + ), + ), + _buildProgressLabel(constraints.biggest), + ], + ); + }), + ); } @override @@ -154,43 +177,16 @@ class _WaveLinearProgressIndicatorState } @override - Widget build(BuildContext context) { - return Container( - constraints: BoxConstraints( - minWidth: double.infinity, - minHeight: _progressLabelHeight, - ), - child: LayoutBuilder(builder: (context, constraints) { - // print('=======layout===$constraints'); - return Stack( - alignment: Alignment.center, - clipBehavior: Clip.none, - children: [ - Center( - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: _minHeight, - minWidth: double.infinity, - ), - child: CustomPaint( - painter: WaveIndicatorPainter( - repaint: _waveController, - progressAnimation: _progressAnimation, - backgroundColor: _backgroundColor, - borderRadius: widget.borderRadius, - waveWidth: widget.waveWidth, - waveBackgroundColor: widget.waveBackgroundColor, - waveStep: widget.waveStep, - waveColor: widget.waveColor, - ), - ), - ), - ), - _buildProgressLabel(constraints.biggest), - ], - ); - }), - ); + void initState() { + _waveController = AnimationController( + vsync: this, duration: const Duration(milliseconds: 5000)); + _waveController.repeat(); + _progressController = AnimationController( + vsync: this, duration: const Duration(milliseconds: 500)); + + _progressAnimation = + Tween(begin: widget.value).animate(_progressController); + super.initState(); } Widget _buildProgressLabel(Size size) { @@ -200,8 +196,17 @@ class _WaveLinearProgressIndicatorState final progressLabelWidth = _getChildSize(_progressLabelKey)?.width ?? 62; final progress = _progressAnimation.value; - double left = size.width * progress; - left = left.clamp(0, size.width - progressLabelWidth); + final isRTL = Directionality.of(context) == TextDirection.rtl; + + double left; + if (isRTL) { + left = size.width * (1 - progress) - progressLabelWidth; + left = left.clamp(0, size.width - progressLabelWidth); + } else { + left = size.width * progress; + left = left.clamp(0, size.width - progressLabelWidth); + } + return Positioned( left: left, height: _progressLabelHeight, diff --git a/lib/wave_linear_progress_indicator.dart b/lib/wave_linear_progress_indicator.dart index 760b3d6..5c8edbd 100644 --- a/lib/wave_linear_progress_indicator.dart +++ b/lib/wave_linear_progress_indicator.dart @@ -1,3 +1,3 @@ -library wave_linear_progress_indicator; +library; export 'src/wave_linear_progress_indicator.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index ce629bf..072ad48 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,13 +1,12 @@ name: wave_linear_progress_indicator description: A linear progress indicator with wave animation in Flutter. version: 0.1.0 -homepage: https://github.com/dev-zhang/wave_linear_progress_indicator -repository: https://github.com/dev-zhang/wave_linear_progress_indicator - +homepage: https://github.com/Mahmoud-Saeed-Mahmoud/wave_linear_progress_indicator.git +repository: https://github.com/Mahmoud-Saeed-Mahmoud/wave_linear_progress_indicator.git environment: - sdk: ">=2.16.2 <3.0.0" - flutter: ">=1.17.0" + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.32.0" dependencies: flutter: @@ -16,13 +15,14 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^1.0.0 + flutter_lints: ^6.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: + uses-material-design: true # To add assets to your package, add an assets section, like this: # assets: diff --git a/test/wave_linear_progress_indicator_test.dart b/test/wave_linear_progress_indicator_test.dart index 0da434d..96b2b32 100644 --- a/test/wave_linear_progress_indicator_test.dart +++ b/test/wave_linear_progress_indicator_test.dart @@ -1,5 +1,69 @@ +import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:wave_linear_progress_indicator/wave_linear_progress_indicator.dart'; void main() { - test('adds one to input values', () {}); -} + group('WaveLinearProgressIndicator', () { + testWidgets('renders correctly in LTR', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: WaveLinearProgressIndicator(value: 0.5), + ), + ), + ); + + expect(find.byType(WaveLinearProgressIndicator), findsOneWidget); + }); + + testWidgets('renders correctly in RTL', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Directionality( + textDirection: TextDirection.rtl, + child: Scaffold( + body: WaveLinearProgressIndicator(value: 0.5), + ), + ), + ), + ); + + expect(find.byType(WaveLinearProgressIndicator), findsOneWidget); + }); + + testWidgets('progress label positioning works in RTL', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Directionality( + textDirection: TextDirection.rtl, + child: Scaffold( + body: SizedBox( + width: 200, + child: WaveLinearProgressIndicator(value: 0.3), + ), + ), + ), + ), + ); + + await tester.pumpAndSettle(); + expect(find.text('30%'), findsOneWidget); + }); + + testWidgets('supports different progress values in RTL', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Directionality( + textDirection: TextDirection.rtl, + child: Scaffold( + body: WaveLinearProgressIndicator(value: 0.75), + ), + ), + ), + ); + + await tester.pumpAndSettle(); + expect(find.text('75%'), findsOneWidget); + }); + }); +} \ No newline at end of file