-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
3,635 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
/pubspec.lock | ||
**/doc/api/ | ||
.dart_tool/ | ||
.packages | ||
build/ | ||
.dart_tool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
version: | ||
revision: 'efbf63d9c66b9f6ec30e9ad4611189aa80003d31' | ||
channel: 'stable' | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## 0.0.1 | ||
|
||
- Describe initial release. | ||
|
||
## 0.0.2 | ||
|
||
- Change README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Maojiu | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Flutter Declarative Syntax Example | ||
|
||
### toListView | ||
|
||
> Using the toListView based on List to make the List become a ListView | ||
```dart | ||
<Widget>[].toListView(); | ||
``` | ||
|
||
### toColumn | ||
|
||
> Using the toColumn based on List to make the List become a Column | ||
```dart | ||
<Widget>[].toColumn(); | ||
``` | ||
|
||
### toRow | ||
|
||
> Using the toRow based on List to make the List become a Row | ||
```dart | ||
<Widget>[].toRow(); | ||
``` | ||
|
||
### toStack | ||
|
||
> Using the toStack based on List to make the List become a Stack | ||
```dart | ||
<Widget>[].toStack(); | ||
``` | ||
|
||
### Add properties and methods using declarative syntax | ||
|
||
```dart | ||
Text("Flutter Declarative Synrax") | ||
.withColor(Colors.pink) | ||
.withFontSize(16) | ||
.withFontWeight(FontWeight.w600) | ||
.backgroundColor(Colors.blue); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
library flutter_declarative_syntax; | ||
|
||
export './src/alignment.dart'; | ||
export './src/button_style.dart'; | ||
export './src/clip.dart'; | ||
export './src/decoration.dart'; | ||
export './src/effect.dart'; | ||
export './src/gesture.dart'; | ||
export './src/icon.dart'; | ||
export './src/layout.dart'; | ||
export './src/list.dart'; | ||
export './src/padding.dart'; | ||
export './src/scroll.dart'; | ||
export './src/sliver.dart'; | ||
export './src/text.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import 'package:flutter/widgets.dart'; | ||
|
||
extension FlutterDeclarativeSyntaxAlignmentModify on Widget { | ||
/// Wraps this widget in an [Align] widget with the specified [alignment]. | ||
/// | ||
/// - Parameter alignment: The alignment of the child widget within its parent. | ||
/// - Parameter key: An optional key to identify the widget. | ||
/// | ||
/// Returns a new [Align] widget with the specified alignment and the current widget as its child. | ||
Widget align( | ||
AlignmentGeometry alignment, { | ||
Key? key, | ||
}) => | ||
Align( | ||
key: key, | ||
alignment: alignment, | ||
child: this, | ||
); | ||
|
||
/// Wraps this widget in an [Align] widget with [Alignment.center] alignment. | ||
/// | ||
/// This method centers the widget within its parent. | ||
Widget alignCenter() => align(Alignment.center); | ||
|
||
/// Wraps this widget in an [Align] widget with [Alignment.centerLeft] alignment. | ||
/// | ||
/// This method aligns the widget to the center left of its parent. | ||
Widget alignLeft() => align(Alignment.centerLeft); | ||
|
||
/// Wraps this widget in an [Align] widget with [Alignment.centerRight] alignment. | ||
/// | ||
/// This method aligns the widget to the center right of its parent. | ||
Widget alignRight() => align(Alignment.centerRight); | ||
|
||
/// Wraps this widget in an [Align] widget with [Alignment.topCenter] alignment. | ||
/// | ||
/// This method aligns the widget to the top center of its parent. | ||
Widget alignTop() => align(Alignment.topCenter); | ||
|
||
/// Wraps this widget in an [Align] widget with [Alignment.bottomCenter] alignment. | ||
/// | ||
/// This method aligns the widget to the bottom center of its parent. | ||
Widget alignBottom() => align(Alignment.bottomCenter); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
extension FlutterDeclarativeSyntaxButtonStyleModify on ButtonStyle { | ||
/// Adds or overrides the text style of the [ButtonStyle]. | ||
ButtonStyle withTextStyle(TextStyle? textStyle) { | ||
return copyWith( | ||
textStyle: MaterialStateProperty.all(textStyle), | ||
); | ||
} | ||
|
||
/// Adds or overrides the background color of the [ButtonStyle]. | ||
ButtonStyle withBackgroundColor(Color? color) { | ||
return copyWith( | ||
backgroundColor: MaterialStateProperty.all(color), | ||
); | ||
} | ||
|
||
/// Adds or overrides the foreground color of the [ButtonStyle]. | ||
ButtonStyle withForegroundColor(Color? color) { | ||
return copyWith( | ||
foregroundColor: MaterialStateProperty.all(color), | ||
); | ||
} | ||
|
||
/// Adds or overrides the overlay color of the [ButtonStyle]. | ||
ButtonStyle withOverlayColor(Color? color) { | ||
return copyWith( | ||
overlayColor: MaterialStateProperty.all(color), | ||
); | ||
} | ||
|
||
/// Adds or overrides the shadow color of the [ButtonStyle]. | ||
ButtonStyle withShadowColor(Color? color) { | ||
return copyWith( | ||
shadowColor: MaterialStateProperty.all(color), | ||
); | ||
} | ||
|
||
/// Adds or overrides the surface tint color of the [ButtonStyle]. | ||
ButtonStyle withSurfaceTintColor(Color? color) { | ||
return copyWith( | ||
surfaceTintColor: MaterialStateProperty.all(color), | ||
); | ||
} | ||
|
||
/// Adds or overrides the elevation of the [ButtonStyle]. | ||
ButtonStyle withElevation(double? elevation) { | ||
return copyWith( | ||
elevation: MaterialStateProperty.all(elevation), | ||
); | ||
} | ||
|
||
/// Adds or overrides the padding of the [ButtonStyle]. | ||
ButtonStyle withPadding(EdgeInsetsGeometry? padding) { | ||
return copyWith( | ||
padding: MaterialStateProperty.all(padding), | ||
); | ||
} | ||
|
||
/// Adds or overrides the minimum size of the [ButtonStyle]. | ||
ButtonStyle withMinimumSize(Size? minimumSize) { | ||
return copyWith( | ||
minimumSize: MaterialStateProperty.all(minimumSize), | ||
); | ||
} | ||
|
||
/// Adds or overrides the fixed size of the [ButtonStyle]. | ||
ButtonStyle withFixedSize(Size? fixedSize) { | ||
return copyWith( | ||
fixedSize: MaterialStateProperty.all(fixedSize), | ||
); | ||
} | ||
|
||
/// Adds or overrides the maximum size of the [ButtonStyle]. | ||
ButtonStyle withMaximumSize(Size? maximumSize) { | ||
return copyWith( | ||
maximumSize: MaterialStateProperty.all(maximumSize), | ||
); | ||
} | ||
|
||
/// Adds or overrides the icon color of the [ButtonStyle]. | ||
ButtonStyle withIconColor(Color? iconColor) { | ||
return copyWith( | ||
iconColor: MaterialStateProperty.all(iconColor), | ||
); | ||
} | ||
|
||
/// Adds or overrides the icon size of the [ButtonStyle]. | ||
ButtonStyle withIconSize(double? iconSize) { | ||
return copyWith( | ||
iconSize: MaterialStateProperty.all(iconSize), | ||
); | ||
} | ||
|
||
/// Adds or overrides the side of the [ButtonStyle]. | ||
ButtonStyle withSide(BorderSide? side) { | ||
return copyWith( | ||
side: MaterialStateProperty.all(side), | ||
); | ||
} | ||
|
||
/// Adds or overrides the shape of the [ButtonStyle]. | ||
ButtonStyle withShape(OutlinedBorder? shape) { | ||
return copyWith( | ||
shape: MaterialStateProperty.all(shape), | ||
); | ||
} | ||
|
||
/// Adds or overrides the mouse cursor of the [ButtonStyle]. | ||
ButtonStyle withMouseCursor(MouseCursor? mouseCursor) { | ||
return copyWith( | ||
mouseCursor: MaterialStateProperty.all(mouseCursor), | ||
); | ||
} | ||
|
||
/// Adds or overrides the visual density of the [ButtonStyle]. | ||
ButtonStyle withVisualDensity(VisualDensity? visualDensity) { | ||
return copyWith( | ||
visualDensity: visualDensity, | ||
); | ||
} | ||
|
||
/// Adds or overrides the tap target size of the [ButtonStyle]. | ||
ButtonStyle withTapTargetSize(MaterialTapTargetSize? tapTargetSize) { | ||
return copyWith( | ||
tapTargetSize: tapTargetSize, | ||
); | ||
} | ||
|
||
/// Adds or overrides the animation duration of the [ButtonStyle]. | ||
ButtonStyle withAnimationDuration(Duration? animationDuration) { | ||
return copyWith( | ||
animationDuration: animationDuration, | ||
); | ||
} | ||
|
||
/// Adds or overrides the enable feedback of the [ButtonStyle]. | ||
ButtonStyle withEnableFeedback(bool? enableFeedback) { | ||
return copyWith( | ||
enableFeedback: enableFeedback, | ||
); | ||
} | ||
|
||
/// Adds or overrides the alignment of the [ButtonStyle]. | ||
ButtonStyle withAlignment(AlignmentGeometry? alignment) { | ||
return copyWith( | ||
alignment: alignment, | ||
); | ||
} | ||
|
||
/// Adds or overrides the splash factory of the [ButtonStyle]. | ||
ButtonStyle withSplashFactory(InteractiveInkFeatureFactory? splashFactory) { | ||
return copyWith( | ||
splashFactory: splashFactory, | ||
); | ||
} | ||
} |
Oops, something went wrong.