[0.1.2]
This commit is contained in:
@@ -21,15 +21,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "flutter_lints",
|
"name": "flutter_lints",
|
||||||
"rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-2.0.3",
|
"rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-5.0.0",
|
||||||
"packageUri": "lib/",
|
"packageUri": "lib/",
|
||||||
"languageVersion": "2.19"
|
"languageVersion": "3.5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "lints",
|
"name": "lints",
|
||||||
"rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/lints-2.1.1",
|
"rootUri": "file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/lints-5.1.1",
|
||||||
"packageUri": "lib/",
|
"packageUri": "lib/",
|
||||||
"languageVersion": "3.0"
|
"languageVersion": "3.6"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "material_color_utilities",
|
"name": "material_color_utilities",
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
"languageVersion": "3.6"
|
"languageVersion": "3.6"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"generated": "2025-03-03T14:15:05.778488Z",
|
"generated": "2025-03-30T10:13:12.420517Z",
|
||||||
"generator": "pub",
|
"generator": "pub",
|
||||||
"generatorVersion": "3.7.0",
|
"generatorVersion": "3.7.0",
|
||||||
"flutterRoot": "file:///C:/Users/micwa/fvm/versions/stable",
|
"flutterRoot": "file:///C:/Users/micwa/fvm/versions/stable",
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ collection
|
|||||||
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.19.1/
|
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.19.1/
|
||||||
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.19.1/lib/
|
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.19.1/lib/
|
||||||
flutter_lints
|
flutter_lints
|
||||||
2.19
|
3.5
|
||||||
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-2.0.3/
|
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-5.0.0/
|
||||||
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-2.0.3/lib/
|
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-5.0.0/lib/
|
||||||
lints
|
lints
|
||||||
3.0
|
3.6
|
||||||
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/lints-2.1.1/
|
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/lints-5.1.1/
|
||||||
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/lints-2.1.1/lib/
|
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/lints-5.1.1/lib/
|
||||||
material_color_utilities
|
material_color_utilities
|
||||||
2.17
|
2.17
|
||||||
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.11.1/
|
file:///C:/Users/micwa/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.11.1/
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
## 0.1.2
|
||||||
|
- **FEAT** Added Quick widget extensions.
|
||||||
|
|
||||||
## 0.1.1
|
## 0.1.1
|
||||||
- **FEAT** Added Map Extensions file and `MergeAllMaps` function.
|
- **FEAT** Added Map Extensions file and `MergeAllMaps` function.
|
||||||
|
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -23,3 +23,20 @@ Developed, Maintained, and is property of Michael W. Aziz (Micazi)
|
|||||||
- on _String_
|
- on _String_
|
||||||
- **toColor()** : Parse a HexCode `String` into a `Color` object. ☑️
|
- **toColor()** : Parse a HexCode `String` into a `Color` object. ☑️
|
||||||
- **capitalize()** : Capitalize the word. ☑️
|
- **capitalize()** : Capitalize the word. ☑️
|
||||||
|
- **rich()** : Convert the string to a RichText Widget. ☑️
|
||||||
|
- on _Widget_
|
||||||
|
- **center**
|
||||||
|
- **circular**
|
||||||
|
- **align**
|
||||||
|
- **positioned**
|
||||||
|
- **sized**
|
||||||
|
- **rotated**
|
||||||
|
- **flipH**
|
||||||
|
- **flipV**
|
||||||
|
- **safeArea**
|
||||||
|
- **opacity**
|
||||||
|
- **padAll**
|
||||||
|
- **padSymH**
|
||||||
|
- **padSymV**
|
||||||
|
- **padTop**
|
||||||
|
- **padBot**
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
library astromic_extensions;
|
library;
|
||||||
|
|
||||||
export './src/border_extensions.dart';
|
export './src/border_extensions.dart';
|
||||||
export './src/insets_extension.dart';
|
export './src/insets_extension.dart';
|
||||||
@@ -7,3 +7,4 @@ export './src/map_extensions.dart';
|
|||||||
export 'src/alignment_extensions.dart';
|
export 'src/alignment_extensions.dart';
|
||||||
export './src/radius_extensions.dart';
|
export './src/radius_extensions.dart';
|
||||||
export './src/string_extensions.dart';
|
export './src/string_extensions.dart';
|
||||||
|
export './src/widget_extensions.dart';
|
||||||
@@ -10,3 +10,11 @@ extension InsetsExtension on EdgeInsetsGeometry {
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension InsetsNumExtension on num {
|
||||||
|
EdgeInsets get symH => EdgeInsets.symmetric(horizontal: toDouble());
|
||||||
|
EdgeInsets get symV => EdgeInsets.symmetric(vertical: toDouble());
|
||||||
|
EdgeInsets get padAll => EdgeInsets.all(toDouble());
|
||||||
|
EdgeInsets get padTop => EdgeInsets.only(top: toDouble());
|
||||||
|
EdgeInsets get padBot => EdgeInsets.only(bottom: toDouble());
|
||||||
|
}
|
||||||
|
|||||||
113
lib/src/widget_extensions.dart
Normal file
113
lib/src/widget_extensions.dart
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
import 'insets_extension.dart';
|
||||||
|
|
||||||
|
extension StringWidgetExtensions on String {
|
||||||
|
/// Convert this text into a RichText with custom quick styles and tap gestures.
|
||||||
|
RichText rich(TextStyle masterStyle, {Map<int, TextStyle>? styles, Map<int, VoidCallback>? tapCallbacks, TextAlign textAlign = TextAlign.center}) {
|
||||||
|
Map<String, TextStyle> mappedStyles = <String, TextStyle>{};
|
||||||
|
Map<String, VoidCallback> mappedCallbacks = <String, VoidCallback>{};
|
||||||
|
|
||||||
|
// Getting string pieces.
|
||||||
|
List<String> stringPieces = RegExp(r'`([^`]*)`').allMatches(this).map((RegExpMatch m) => m.group(1)).whereType<String>().toList();
|
||||||
|
|
||||||
|
// Looping on the pieces...
|
||||||
|
for (String stringPiece in stringPieces) {
|
||||||
|
String textAfter = split('`$stringPiece`')[1];
|
||||||
|
String textBeforeNext = textAfter.split('`')[0];
|
||||||
|
if (RegExp(r'{(\d+)}').hasMatch(textBeforeNext)) {
|
||||||
|
// The current piece has an index
|
||||||
|
int? itemIndex = int.tryParse(RegExp(r'{(\d+)}').allMatches(textBeforeNext).map((RegExpMatch m) => m.group(1)).whereType<String>().first);
|
||||||
|
if (itemIndex != null) {
|
||||||
|
// Styles
|
||||||
|
if (styles != null && styles.isNotEmpty && styles.keys.contains(itemIndex)) {
|
||||||
|
// Custom Style
|
||||||
|
mappedStyles.addEntries(<MapEntry<String, TextStyle>>[MapEntry<String, TextStyle>(stringPiece, styles[itemIndex]!)]);
|
||||||
|
} else {
|
||||||
|
// Master
|
||||||
|
mappedStyles.addEntries(<MapEntry<String, TextStyle>>[MapEntry<String, TextStyle>(stringPiece, masterStyle)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Callbacks
|
||||||
|
if (tapCallbacks != null && tapCallbacks.isNotEmpty && tapCallbacks.keys.contains(itemIndex)) {
|
||||||
|
// Add tap callbak
|
||||||
|
mappedCallbacks.addEntries(<MapEntry<String, VoidCallback>>[MapEntry<String, VoidCallback>(stringPiece, tapCallbacks[itemIndex]!)]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
debugPrint('Something wrong with applying custom indexing in QuickRichText. $itemIndex');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mappedStyles.addEntries(<MapEntry<String, TextStyle>>[MapEntry<String, TextStyle>(stringPiece, masterStyle)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Adding styles to the children
|
||||||
|
List<InlineSpan> children = mappedStyles.entries
|
||||||
|
.toList()
|
||||||
|
.sublist(1)
|
||||||
|
.map((MapEntry<String, TextStyle> entry) => TextSpan(
|
||||||
|
text: entry.key,
|
||||||
|
style: entry.value,
|
||||||
|
recognizer: mappedCallbacks.containsKey(entry.key) ? (TapGestureRecognizer()..onTap = mappedCallbacks[entry.key]) : null,
|
||||||
|
))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
text: stringPieces[0],
|
||||||
|
style: masterStyle,
|
||||||
|
children: children,
|
||||||
|
),
|
||||||
|
textAlign: textAlign,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension QuickSimpleWidgets on Widget {
|
||||||
|
/// Center the widget
|
||||||
|
Widget get center => Center(child: this);
|
||||||
|
|
||||||
|
/// Make the widget circular with RRect
|
||||||
|
Widget get circular => ClipRRect(borderRadius: BorderRadius.circular(10000000), child: this);
|
||||||
|
|
||||||
|
/// Wrap with a SizedBox
|
||||||
|
Widget sized({num? w, num? h}) => SizedBox(width: w?.toDouble(), height: h?.toDouble(), child: this);
|
||||||
|
|
||||||
|
/// Wrap with a Positioned
|
||||||
|
Widget positioned({num? bottom, num? top}) => Positioned(bottom: bottom?.toDouble(), top: top?.toDouble(), child: this);
|
||||||
|
|
||||||
|
/// Rotate the widget in quarter turns
|
||||||
|
Widget rotated({int quarterTurns = 0}) => Transform.rotate(angle: (math.pi * 22.5) * quarterTurns, child: this);
|
||||||
|
|
||||||
|
//TODO - Make it directional
|
||||||
|
/// Align
|
||||||
|
Widget align(Alignment a) => Align(alignment: a, child: this);
|
||||||
|
|
||||||
|
/// Flip the widget horizontally
|
||||||
|
Widget get flipH => Transform.flip(flipX: true, child: this);
|
||||||
|
|
||||||
|
/// Flip the widget vertically
|
||||||
|
Widget get flipV => Transform.flip(flipY: true, child: this);
|
||||||
|
|
||||||
|
/// Wrap with a SafeArea
|
||||||
|
Widget get safeArea => SafeArea(child: this);
|
||||||
|
|
||||||
|
/// Quick Opacity Adjustment
|
||||||
|
Widget opacity(num o) => Opacity(opacity: o.toDouble(), child: this);
|
||||||
|
|
||||||
|
/// Padding padAll
|
||||||
|
Widget padAll(num p) => Padding(padding: p.padAll, child: this);
|
||||||
|
|
||||||
|
/// Padding Symmetric Horizontally
|
||||||
|
Widget padSymH(num p) => Padding(padding: p.symH, child: this);
|
||||||
|
|
||||||
|
/// Padding Symmetric Vertically
|
||||||
|
Widget padSymV(num p) => Padding(padding: p.symV, child: this);
|
||||||
|
//
|
||||||
|
/// Padding Only Top
|
||||||
|
Widget padTop(num p) => Padding(padding: p.padTop, child: this);
|
||||||
|
|
||||||
|
/// Padding Only Bottom
|
||||||
|
Widget padBot(num p) => Padding(padding: p.padBot, child: this);
|
||||||
|
}
|
||||||
@@ -26,18 +26,18 @@ packages:
|
|||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: flutter_lints
|
name: flutter_lints
|
||||||
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
|
sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "5.0.0"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: lints
|
name: lints
|
||||||
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
|
sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "5.1.1"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
name: astromic_extensions
|
name: astromic_extensions
|
||||||
description: The extensions module of the Astromic Presentation System.
|
description: The extensions module of the Astromic Presentation System.
|
||||||
publish_to: "none"
|
publish_to: "none"
|
||||||
version: 0.1.1
|
version: 0.1.2
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.6.0"
|
sdk: ">=3.6.0"
|
||||||
flutter: ">3.27.0"
|
flutter: ">3.27.0"
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^2.0.3
|
flutter_lints: ^5.0.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
|||||||
Reference in New Issue
Block a user