Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Flutter 3.10 #59

Open
wants to merge 4 commits into
base: 2.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [1.1.0]

* Update internal dependencies
* Update minimum Dart version to 2.0
* Update minimum Flutter version to 3.16

## [1.0.1]
* Fix a bug where `TextDrawable`s would incorrectly render on the final image ([Issue #19](https://github.com/omarhurani/flutter_painter/issues/19)).
* Add Flutter linting using [flutter_lints](https://pub.dev/packages/flutter_lints) ([Issue #20](https://github.com/omarhurani/flutter_painter/issues/20)).
Expand Down
30 changes: 1 addition & 29 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can bpackage:flutter_lints/flutter.yamle customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
avoid_print: true # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
include: package:flutter_lints/flutter.yaml
80 changes: 37 additions & 43 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_painter/flutter_painter.dart';
Expand All @@ -12,25 +9,22 @@ import 'package:phosphor_flutter/phosphor_flutter.dart';
void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
return const MaterialApp(
home: FlutterPainterExample(),
title: "Flutter Painter Example",
theme: ThemeData(
primaryColor: Colors.brown, accentColor: Colors.amberAccent),
home: const FlutterPainterExample(),
);
}
}

class FlutterPainterExample extends StatefulWidget {
const FlutterPainterExample({Key? key}) : super(key: key);
const FlutterPainterExample({super.key});

@override
_FlutterPainterExampleState createState() => _FlutterPainterExampleState();
State<FlutterPainterExample> createState() => _FlutterPainterExampleState();
}

class _FlutterPainterExampleState extends State<FlutterPainterExample> {
Expand Down Expand Up @@ -133,8 +127,8 @@ class _FlutterPainterExampleState extends State<FlutterPainterExample> {
actions: [
// Delete the selected drawable
IconButton(
icon: const Icon(
PhosphorIcons.trash,
icon: PhosphorIcon(
PhosphorIcons.trash(),
),
onPressed: controller.selectedObjectDrawable == null
? null
Expand All @@ -152,15 +146,15 @@ class _FlutterPainterExampleState extends State<FlutterPainterExample> {
),
// Redo action
IconButton(
icon: const Icon(
PhosphorIcons.arrowClockwise,
icon: PhosphorIcon(
PhosphorIcons.arrowClockwise(),
),
onPressed: controller.canRedo ? redo : null,
),
// Undo action
IconButton(
icon: const Icon(
PhosphorIcons.arrowCounterClockwise,
icon: PhosphorIcon(
PhosphorIcons.arrowCounterClockwise(),
),
onPressed: controller.canUndo ? undo : null,
),
Expand All @@ -170,10 +164,10 @@ class _FlutterPainterExampleState extends State<FlutterPainterExample> {
),
// Generate image
floatingActionButton: FloatingActionButton(
child: const Icon(
PhosphorIcons.imageFill,
),
onPressed: renderAndDisplayImage,
child: PhosphorIcon(
PhosphorIcons.image(PhosphorIconsStyle.fill),
),
),
body: Stack(
children: [
Expand Down Expand Up @@ -394,38 +388,38 @@ class _FlutterPainterExampleState extends State<FlutterPainterExample> {
children: [
// Free-style eraser
IconButton(
icon: Icon(
PhosphorIcons.eraser,
icon: PhosphorIcon(
PhosphorIcons.eraser(),
color: controller.freeStyleMode == FreeStyleMode.erase
? Theme.of(context).accentColor
? Theme.of(context).colorScheme.secondary
: null,
),
onPressed: toggleFreeStyleErase,
),
// Free-style drawing
IconButton(
icon: Icon(
PhosphorIcons.scribbleLoop,
icon: PhosphorIcon(
PhosphorIcons.scribbleLoop(),
color: controller.freeStyleMode == FreeStyleMode.draw
? Theme.of(context).accentColor
? Theme.of(context).colorScheme.secondary
: null,
),
onPressed: toggleFreeStyleDraw,
),
// Add text
IconButton(
icon: Icon(
PhosphorIcons.textT,
icon: PhosphorIcon(
PhosphorIcons.textT(),
color: textFocusNode.hasFocus
? Theme.of(context).accentColor
? Theme.of(context).colorScheme.secondary
: null,
),
onPressed: addText,
),
// Add sticker image
IconButton(
icon: const Icon(
PhosphorIcons.sticker,
icon: PhosphorIcon(
PhosphorIcons.sticker(),
),
onPressed: addSticker,
),
Expand Down Expand Up @@ -460,7 +454,7 @@ class _FlutterPainterExampleState extends State<FlutterPainterExample> {
child: Icon(
getShapeIcon(controller.shapeFactory),
color: controller.shapeFactory != null
? Theme.of(context).accentColor
? Theme.of(context).colorScheme.secondary
: null,
),
),
Expand All @@ -469,7 +463,7 @@ class _FlutterPainterExampleState extends State<FlutterPainterExample> {
IconButton(
icon: Icon(
getShapeIcon(controller.shapeFactory),
color: Theme.of(context).accentColor,
color: Theme.of(context).colorScheme.secondary,
),
onPressed: () => selectShape(null),
),
Expand All @@ -484,14 +478,16 @@ class _FlutterPainterExampleState extends State<FlutterPainterExample> {
}

static IconData getShapeIcon(ShapeFactory? shapeFactory) {
if (shapeFactory is LineFactory) return PhosphorIcons.lineSegment;
if (shapeFactory is ArrowFactory) return PhosphorIcons.arrowUpRight;
if (shapeFactory is LineFactory) return PhosphorIcons.lineSegment();
if (shapeFactory is ArrowFactory) return PhosphorIcons.arrowUpRight();
if (shapeFactory is DoubleArrowFactory) {
return PhosphorIcons.arrowsHorizontal;
return PhosphorIcons.arrowsHorizontal();
}
if (shapeFactory is RectangleFactory) {
return PhosphorIcons.rectangle();
}
if (shapeFactory is RectangleFactory) return PhosphorIcons.rectangle;
if (shapeFactory is OvalFactory) return PhosphorIcons.circle;
return PhosphorIcons.polygon;
if (shapeFactory is OvalFactory) return PhosphorIcons.circle();
return PhosphorIcons.polygon();
}

void undo() {
Expand Down Expand Up @@ -607,8 +603,7 @@ class _FlutterPainterExampleState extends State<FlutterPainterExample> {
class RenderedImageDialog extends StatelessWidget {
final Future<Uint8List?> imageFuture;

const RenderedImageDialog({Key? key, required this.imageFuture})
: super(key: key);
const RenderedImageDialog({super.key, required this.imageFuture});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -637,8 +632,7 @@ class RenderedImageDialog extends StatelessWidget {
class SelectStickerImageDialog extends StatelessWidget {
final List<String> imagesLinks;

const SelectStickerImageDialog({Key? key, this.imagesLinks = const []})
: super(key: key);
const SelectStickerImageDialog({super.key, this.imagesLinks = const []});

@override
Widget build(BuildContext context) {
Expand Down
Loading