File tree Expand file tree Collapse file tree 10 files changed +84
-7
lines changed
Expand file tree Collapse file tree 10 files changed +84
-7
lines changed Original file line number Diff line number Diff line change 1+ .dart_tool/
2+ .flutter-plugins-dependencies
3+ .idea/
4+ .metadata
5+ .vscode/
6+ .git/
7+ .github/
8+ *.iml
9+ *.log
10+ build/
11+ coverage/
12+ pubspec.lock
13+
14+ # Examples
15+ example/assets
16+ example/android
17+ example/ios
18+ example/macos
19+ example/web
20+ example/linux
21+ example/windows
22+ example/.dart_tool/
23+ example/build/
24+ example/pubspec.lock
25+ example/.flutter-plugins-dependencies
26+
27+ # README assets
28+ assets/
Original file line number Diff line number Diff line change 11# Sticker Widget
22
3- Fully customizable core sticker widgets you can drop into any flutter app .
3+ Draggable, rotatable, resizable and customizable sticker widgets for Flutter .
44
55<p align =" center " >
6- <img src =" https://github.com/blossomdiary/sticker_widget/raw/main/docs /thumbnail.png " alt =" demo " />
6+ <img src =" https://github.com/blossomdiary/sticker_widget/raw/main/assets /thumbnail.png " alt =" demo " />
77</p >
88
99## Features
File renamed without changes.
Original file line number Diff line number Diff line change 1+ /// Model describing an image sticker.
12class PictureModel {
3+ /// Image URL or asset path.
24 String stringUrl;
5+
6+ /// Top position inside the sticker bounds.
37 double top;
8+
9+ /// Whether the sticker is currently selected.
410 bool isSelected;
11+
12+ /// Rotation in radians.
513 double angle;
614
7- /// Scale image
15+ /// Scale factor for the image.
816 double scale;
17+
18+ /// Left position inside the sticker bounds.
919 double left;
1020
21+ /// Creates a picture sticker model.
1122 PictureModel (
1223 {required this .stringUrl,
1324 required this .top,
@@ -16,6 +27,7 @@ class PictureModel {
1627 required this .scale,
1728 required this .left});
1829
30+ /// Creates a picture sticker from a URL or asset path.
1931 factory PictureModel .fromUrl (
2032 String url, {
2133 double top = 0 ,
@@ -34,6 +46,7 @@ class PictureModel {
3446 );
3547 }
3648
49+ /// Creates a model from a JSON map.
3750 PictureModel .fromJson (Map <String , dynamic > data)
3851 : stringUrl = data['url' ] ?? '' ,
3952 top = data['top' ] ?? 0 ,
@@ -42,6 +55,7 @@ class PictureModel {
4255 scale = data['scale' ] ?? 1 ,
4356 isSelected = false ;
4457
58+ /// Serializes the model to JSON.
4559 Map <String , dynamic > toJson () {
4660 return {
4761 'url' : stringUrl,
Original file line number Diff line number Diff line change 11import 'package:flutter/material.dart' ;
22
3+ /// Model describing a text sticker.
34class TextModel {
5+ /// Displayed text.
46 String name;
7+
8+ /// Text style for rendering.
59 TextStyle textStyle;
10+
11+ /// Top position inside the sticker bounds.
612 double top;
13+
14+ /// Left position inside the sticker bounds.
715 double left;
16+
17+ /// Whether the sticker is currently selected.
818 bool isSelected;
19+
20+ /// Rotation in radians.
921 double angle;
22+
23+ /// Text alignment.
1024 TextAlign textAlign;
25+
26+ /// Scale factor for the text.
1127 double scale;
1228
29+ /// Creates a text sticker model.
1330 TextModel (
1431 {required this .name,
1532 required this .textStyle,
@@ -20,6 +37,7 @@ class TextModel {
2037 required this .scale,
2138 required this .left});
2239
40+ /// Creates a text sticker from a string.
2341 factory TextModel .fromText (
2442 String text, {
2543 TextStyle ? textStyle,
@@ -42,6 +60,7 @@ class TextModel {
4260 );
4361 }
4462
63+ /// Creates a model from a JSON map.
4564 TextModel .fromJson (Map <String , dynamic > data)
4665 : name = data['text' ] ?? '' ,
4766 textStyle = TextStyle (
@@ -65,6 +84,7 @@ class TextModel {
6584 isSelected = false ,
6685 textAlign = TextAlign .values[data['textAlign' ] ?? 0 ];
6786
87+ /// Serializes the model to JSON.
6888 Map <String , dynamic > toJson () {
6989 return {
7090 'text' : name,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
44
55import '../model/picture_model.dart' ;
66
7+ /// Editable sticker widget for images.
78class PictureEditingBox extends StatefulWidget {
89 /// Your widget should be move within this [boundWidth]
910 final double boundWidth;
@@ -20,6 +21,7 @@ class PictureEditingBox extends StatefulWidget {
2021 /// If you use onTap then you Have to manage IsSelected field in PicturModel
2122 final Function ()? onTap;
2223
24+ /// Disables interaction when true.
2325 final bool viewOnly;
2426
2527 /// Custom controller Icons
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import '../model/text_model.dart';
55import 'sticker_box.dart' ;
66import 'text_box.dart' ;
77
8+ /// Wrapper that renders either a picture or text sticker.
89class StickerWidget extends StatelessWidget {
910 /// Your widget should be move within this [boundWidth]
1011 final double boundWidth;
@@ -21,6 +22,7 @@ class StickerWidget extends StatelessWidget {
2122 /// If you use onTap then you Have to manage IsSelected field in model
2223 final VoidCallback ? onTap;
2324
25+ /// Disables interaction when true.
2426 final bool viewOnly;
2527
2628 /// Custom controller Icons
@@ -32,6 +34,7 @@ class StickerWidget extends StatelessWidget {
3234 /// Custom request to edit text. When provided, the default dialog is skipped.
3335 final TextEditRequest ? onTextEditRequest;
3436
37+ /// Creates a sticker widget for either a [PictureModel] or [TextModel] .
3538 const StickerWidget ({
3639 super .key,
3740 required this .boundWidth,
Original file line number Diff line number Diff line change @@ -3,10 +3,11 @@ import 'package:flutter/material.dart';
33
44import '../model/text_model.dart' ;
55
6+ /// Callback for providing a custom text editing flow.
67typedef TextEditRequest =
78 Future <String ?> Function (BuildContext context, String currentText);
89
9- // ignore: must_be_immutable
10+ /// Editable sticker widget for text.
1011class TextEditingBox extends StatefulWidget {
1112 /// TextModel for your text
1213 final TextModel textModel;
@@ -17,7 +18,8 @@ class TextEditingBox extends StatefulWidget {
1718 /// Your widget should be move within this [boundHeight]
1819 final double boundHeight;
1920
20- bool viewOnly;
21+ /// Disables interaction when true.
22+ final bool viewOnly;
2123
2224 /// Custom controller Icons
2325 final Icon ? editIcon;
Original file line number Diff line number Diff line change 1+ /// Sticker widgets and models for draggable, resizable, rotatable content.
12library ;
23
34export 'src/model/picture_model.dart' ;
Original file line number Diff line number Diff line change 11name : sticker_widget
2- description : " A new Flutter package project. "
2+ description : Draggable, rotatable, and resizable sticker widgets for Flutter.
33version : 0.0.1
4- homepage :
4+ homepage : https://blossomdiary.dev
5+ repository : https://github.com/blossomdiary/sticker_widget
6+ topics :
7+ - sticker
8+ - widget
9+ - editor
10+ - image
11+ - text
512
613environment :
714 sdk : ^3.10.7
You can’t perform that action at this time.
0 commit comments