flutter_simple_sticker_view 1.0.0 flutter_simple_sticker_view: ^1.0.0 copied to clipboard
A new flutter plugin project for attach stickers on image, as you want. attached image can also be export.
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter_simple_sticker_view/flutter_simple_sticker_view.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:permission_handler/permission_handler.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(title: "Flutter Simple Sticker View", home: HomeView());
}
}
class HomeView extends StatefulWidget {
@override
_HomeViewState createState() => _HomeViewState();
}
class _HomeViewState extends State<HomeView> {
FlutterSimpleStickerView _stickerView = FlutterSimpleStickerView(
Container(
decoration: BoxDecoration(
color: Colors.red,
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
"https://images.unsplash.com/photo-1544032527-042957c6f7ce?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"))),
),
[
Image.asset("assets/icons8-superman-50.png"),
Image.asset("assets/icons8-captain-america-50.png"),
Image.asset("assets/icons8-avengers-50.png"),
Image.asset("assets/icons8-iron-man-50.png"),
Image.asset("assets/icons8-batman-50.png"),
Image.asset("assets/icons8-thor-50.png"),
Image.asset("assets/icons8-venom-head-50.png"),
Image.asset("assets/icons8-homer-simpson-50.png"),
Image.asset("assets/icons8-spider-man-head-50.png"),
Image.asset("assets/icons8-harry-potter-50.png"),
Image.asset("assets/icons8-genie-lamp-50.png"),
Image.asset("assets/icons8-cyborg-50.png"),
Image.asset("assets/icons8-one-ring-50.png"),
],
// panelHeight: 150,
// panelBackgroundColor: Colors.blue,
// panelStickerBackgroundColor: Colors.pink,
// panelStickercrossAxisCount: 4,
// panelStickerAspectRatio: 1.0,
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Flutter Simple Sticker View"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.save_alt),
onPressed: () async {
Uint8List image = await _stickerView.exportImage();
Map<PermissionGroup, PermissionStatus> permissions =
await PermissionHandler()
.requestPermissions([PermissionGroup.storage]);
await ImageGallerySaver.saveImage(image);
},
)
],
),
body: _stickerView);
}
}