Skip to content

Commit b402ea5

Browse files
committed
Refactor for Flutter-only extensions and package split
Split Flutter-specific extensions into mayr_flutter_extensions, removing all general Dart extensions (String, DateTime, Number, etc.) and related tests. Updated README, CHANGELOG, LICENSE, and example to reflect the new package structure and usage. Added CONTRIBUTING.md and .github/agents/README.md for contributor guidance. Introduced lib/mayr_flutter_extensions.dart as the main export, and cleaned up imports to only include Flutter-relevant extensions.
1 parent 5211832 commit b402ea5

28 files changed

+956
-1092
lines changed

.github/agents/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# GitHub Copilot Agent Instructions
2+
3+
This directory contains instructions for GitHub Copilot agents working on this repository.
4+
5+
## Flutter Package Structure
6+
7+
This is a Flutter package that provides Flutter-specific extension methods. The package works in conjunction with `mayr_dart_extensions` which provides general Dart extensions.
8+
9+
### Key Guidelines
10+
11+
- **Flutter-Only Focus**: This package should only contain extensions specific to Flutter SDK (widgets, BuildContext, etc.)
12+
- **Dart Extensions**: General Dart type extensions (String, int, DateTime, Duration, etc.) belong in `mayr_dart_extensions`
13+
- **No Duplication**: Do not add extensions that duplicate functionality from `mayr_dart_extensions`
14+
15+
### Testing Requirements
16+
17+
- All extension methods must have corresponding tests
18+
- Run `flutter test` to execute tests
19+
- Use `dart format .` to format code
20+
- Use `dart analyze .` to check for issues
21+
22+
### Code Style
23+
24+
- Follow the existing code patterns in the package
25+
- Use descriptive method names
26+
- Add comprehensive dartdoc comments with examples
27+
- Keep methods focused and single-purpose
28+
29+
### Related Packages
30+
31+
- **mayr_dart_extensions**: General Dart extensions (https://pub.dev/packages/mayr_dart_extensions)
32+
- Users typically install both packages together in Flutter apps

CHANGELOG.md

Lines changed: 83 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -5,93 +5,88 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.3.1]
9-
10-
- Automated deployments
11-
12-
## [0.3.0] - 30th April, 2025
13-
14-
### Added
15-
- `context.platformInLightMode`
16-
- `dateTime.startOfDay()`
17-
- `MayrDateTimeFormats`: A collection of popular datetime formats
18-
- Slightly more tests and dartdocs
19-
20-
### Changed
21-
- `dateTime.toFormat(...)` -> `dateTime.format(...)`
22-
- `dateTime.isYesterday()`, `dateTime.isToday()`, and `dateTime.isTomorrow()` are now getter properties:
23-
- `dateTime.isYesterday`
24-
- `dateTime.isToday`
25-
- `dateTime.isTomorrow`
26-
- `dateTime.isInPast()` and `dateTime.isInFuture()` are also now getter properties:
27-
- `dateTime.isInPast`
28-
- `dateTime.isInFuture`
29-
30-
### Removed
31-
- `dateTime.toDateString(...)`
32-
- `dateTime.toDateStringUK(...)`
33-
- `dateTime.toDateStringUS(...)`
34-
- `dateTime.toDateTimeString(...)`
35-
- `dateTime.isExpired()`
36-
37-
## [0.2.0] - [29-04-2025]
38-
39-
### Added
40-
- `T?.orDefault(T fallback)` Added
41-
- `String.copyToClipboard()` Added
42-
- `String.toUri()` Added
43-
- More dartdocs to properties and methods
44-
45-
### Changed
46-
- `String.toDateTime()` now uses tryParse, so null is returned if parse fails and error is not thrown
47-
- Added namespaces to extensions to prevent clash with user extensions
48-
49-
50-
## [0.1.1] - Minor cleanups
51-
52-
### Changed
53-
- Removed certain files that are not required to use package from pub
54-
55-
56-
## [0.1.0] - Rebrand to mayr_*
57-
58-
### Changed
59-
- Package name was rebranded from `flutter_util_extensions` to `mayr_extensions`
60-
61-
62-
## [0.0.2]
63-
64-
### Changed
65-
- Relaxed `intl` dependency constraint to `>=0.19.0 <0.21.0` for wider compatibility.
66-
67-
68-
## [0.0.1] - Initial Release
69-
70-
### Added
71-
- BuildContext extensions:
72-
- Access to form, navigator, overlay, scaffold, media query, brightness, platform checks, and widget size.
73-
- Device type checks (phone, tablet, desktop).
74-
- Added `showSnackBar()` utility method.
75-
- DateTime extensions:
76-
- Checkers for time of day, expiry, and comparisons.
77-
- Manipulators to add/subtract dates, months, years, etc.
78-
- Conversions to various string formats and age calculation.
79-
- Duration extension:
80-
- `delay()` method for simple async delays.
81-
- Dynamic extensions:
82-
- `nullOnDebug()`, `onlyOnDebug()`, and `maybe()` based on probability.
83-
- Image extension:
84-
- Easily create a `CircleAvatar` widget with an image.
85-
- Number extensions:
86-
- Comparison helpers, random number generators, number formatters, and conversions to Duration.
87-
- String extensions:
88-
- Pattern matching, parsing to different cases (camelCase, snakeCase, etc.), and pretty printing (JSON, YAML, XML).
89-
- Pattern checkers for emails, URLs, IP addresses, and more.
90-
- Widget extensions:
91-
- Helpers for padding, sizing, positioning, clipping, visibility, and touch management via `InkWellManager`.
92-
93-
### Notes
94-
- First public release.
95-
- Still evolving — contributions and feedback welcome!
8+
## [1.0.0] - 2025-01-17
9+
10+
### 🎉 Initial Release
11+
12+
This is the first release of **mayr_flutter_extensions** as a standalone Flutter-specific extension package, separated from the original `mayr_extensions` package.
13+
14+
### Package Philosophy
15+
16+
This package is part of the **MayR Extensions** family:
17+
- **mayr_dart_extensions** - General Dart extensions (String, int, DateTime, Duration, List, Map, etc.)
18+
- **mayr_flutter_extensions** - Flutter-specific extensions (Widget, BuildContext, etc.)
19+
20+
This separation ensures:
21+
- Pure Dart projects can use general extensions without Flutter dependencies
22+
- Flutter projects can use both packages together for complete functionality
23+
- No code duplication between packages
24+
- Cleaner, more focused codebases
25+
26+
### Features
27+
28+
#### 🧱 BuildContext Extensions
29+
- **Navigation & State Access**: `navigator`, `scaffold`, `form`, `overlay`, `scaffoldMessenger`
30+
- **SnackBar Helper**: `showSnackBar()` for quick snackbar display
31+
- **Media Query**: `mediaQuery`, `widgetSize`, `widgetWidth`, `widgetHeight`, `widgetShortestSide`
32+
- **Theme & Brightness**: `platformBrightness`, `platformInDarkMode`, `platformInLightMode`
33+
- **Device Detection**: `orientation`, `isPortrait`, `isLandscape`, `isPhone`, `isSmallTablet`, `isLargeTablet`, `isTablet`, `isDesktop`
34+
35+
#### 🎨 Widget Extensions
36+
- **Basic Transformations**: `center()`, `expanded()`, `flexible()`, `opacity()`, `sizedBox()`, `constrained()`
37+
- **Padding**: `paddingAll()`, `paddingSymmetric()`, `paddingOnly()`, `paddingZero()`
38+
- **Clipping**: `clipRect()`, `clipRRect()`, `clipRounded()`
39+
- **Positioning**: `positionAlign()`, `positionedFill()`
40+
- **Visibility Helpers**: `showIf()`, `hideIf()`, `showUnless()`, `hideUnless()`
41+
42+
#### 🔘 Tap Interactions
43+
- **InkWellManager**: Helper class for cleaner tap handling
44+
- `inkWellManager()` - Setup tap handler
45+
- `onTap()` - Single tap
46+
- `onDoubleTap()` - Double tap
47+
- `onLongPress()` - Long press
48+
49+
#### 🖼️ Image Extensions
50+
- `circleAvatar()` - Convert Image to CircleAvatar with customization options
51+
52+
### Changed from Original Package
53+
54+
#### Removed (Now in mayr_dart_extensions)
55+
- Bool extensions (choose, toInt, toYesNo, not)
56+
- String extensions (camelCase, snakeCase, mask, isEmail, etc.)
57+
- Number extensions (clampMin, clampMax, formatAsCurrency, etc.)
58+
- DateTime extensions (addDays, format, toAge, etc.)
59+
- Duration extensions (delay, toReadableString, etc.)
60+
- List/Iterable extensions (firstOrNull, chunked, mapIndexed, etc.)
61+
- Map extensions (getOrNull, mapKeys, merge, etc.)
62+
- Set extensions (toggle, intersects, isSubsetOf, etc.)
63+
- Object extensions (let, also)
64+
- Dynamic extensions (nullOnDebug, maybe, orDefault)
65+
- Humanize extensions (humanizeNumber, humanizeOrdinal, etc.)
66+
- MayrDateTimeFormats utility class
67+
68+
### Migration Guide
69+
70+
If you were using the original `mayr_extensions` package:
71+
72+
1. **Install both packages**:
73+
```yaml
74+
dependencies:
75+
mayr_dart_extensions: ^1.0.0
76+
mayr_flutter_extensions: ^1.0.0
77+
```
78+
79+
2. **Update imports**:
80+
```dart
81+
// For general Dart extensions
82+
import 'package:mayr_dart_extensions/mayr_dart_extensions.dart';
83+
84+
// For Flutter-specific extensions
85+
import 'package:mayr_flutter_extensions/mayr_flutter_extensions.dart';
86+
```
87+
88+
3. **No code changes needed** - All extensions work the same way, they're just in different packages now!
9689

9790
---
91+
92+
For older versions, see the history of the original `mayr_extensions` package.

0 commit comments

Comments
 (0)