Skip to content

Commit

Permalink
Upgrade to flutter 3.27
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 11, 2024
1 parent f9a4e1b commit 8dc1189
Show file tree
Hide file tree
Showing 41 changed files with 148 additions and 107 deletions.
20 changes: 10 additions & 10 deletions api/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "45cfa8471b89fb6643fe9bf51bd7931a76b8f5ec2d65de4fb176dba8d4f22c77"
sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab"
url: "https://pub.dev"
source: hosted
version: "73.0.0"
version: "76.0.0"
_macros:
dependency: transitive
description: dart
source: sdk
version: "0.3.2"
version: "0.3.3"
analyzer:
dependency: "direct dev"
description:
name: analyzer
sha256: "4959fec185fe70cce007c57e9ab6983101dbe593d2bf8bbfb4453aaec0cf470a"
sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e"
url: "https://pub.dev"
source: hosted
version: "6.8.0"
version: "6.11.0"
archive:
dependency: "direct main"
description:
Expand Down Expand Up @@ -298,10 +298,10 @@ packages:
dependency: "direct dev"
description:
name: lints
sha256: "3315600f3fb3b135be672bf4a178c55f274bebe368325ae18462c89ac1e3b413"
sha256: "4a16b3f03741e1252fda5de3ce712666d010ba2122f8e912c94f9f7b90e1a4c3"
url: "https://pub.dev"
source: hosted
version: "5.0.0"
version: "5.1.0"
logging:
dependency: transitive
description:
Expand All @@ -323,10 +323,10 @@ packages:
dependency: transitive
description:
name: macros
sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536"
sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656"
url: "https://pub.dev"
source: hosted
version: "0.1.2-main.4"
version: "0.1.3-main.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -664,4 +664,4 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.5.0 <4.0.0"
dart: ">=3.6.0-0 <4.0.0"
2 changes: 1 addition & 1 deletion app/lib/cubits/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class InputConfiguration with _$InputConfiguration {
firstPenButton,
secondPenButton,
touch
}.whereNotNull().toSet();
}.nonNulls.toSet();
}

enum SortBy { name, created, modified }
Expand Down
3 changes: 1 addition & 2 deletions app/lib/dialogs/area/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:butterfly/helpers/point.dart';
import 'package:butterfly/helpers/rect.dart';
import 'package:butterfly/widgets/context_menu.dart';
import 'package:butterfly_api/butterfly_api.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand Down Expand Up @@ -72,7 +71,7 @@ ContextMenuBuilder buildAreaContextMenu(DocumentBloc bloc,
.map((e) => e.transform(
position: -area.position.toOffset(), relative: true))
.map((e) => e?.element)
.whereNotNull()
.nonNulls
.toList(),
)(context)
];
Expand Down
7 changes: 3 additions & 4 deletions app/lib/dialogs/elements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:butterfly/services/export.dart';
import 'package:butterfly/visualizer/event.dart';
import 'package:butterfly/widgets/context_menu.dart';
import 'package:butterfly_api/butterfly_api.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:lw_sysapi/lw_sysapi.dart';
Expand Down Expand Up @@ -92,7 +91,7 @@ ContextMenuBuilder buildElementsContextMenu(
final state = bloc.state;
if (state is! DocumentLoadSuccess) return;
bloc.add(ElementsRemoved(
renderers.map((r) => r.element.id).whereNotNull().toList()));
renderers.map((r) => r.element.id).nonNulls.toList()));
},
icon: const PhosphorIcon(PhosphorIconsLight.trash),
label: AppLocalizations.of(context).delete,
Expand All @@ -111,7 +110,7 @@ ContextMenuBuilder buildElementsContextMenu(
e,
renderers
.map((r) => r.element.id)
.whereNotNull()
.nonNulls
.toList()));
},
))
Expand All @@ -130,7 +129,7 @@ ContextMenuBuilder buildElementsContextMenu(
onPressed: () {
operations.values
.map((v) => v[e])
.whereNotNull()
.nonNulls
.forEach((e) => e(bloc, context));
if (context.mounted) Navigator.of(context).pop(true);
},
Expand Down
2 changes: 1 addition & 1 deletion app/lib/dialogs/packs/color_pick.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class _ColorPalettePickerDialogState extends State<ColorPalettePickerDialog> {
child: Material(
color: Theme.of(context)
.scaffoldBackgroundColor
.withOpacity(0.5),
.withValues(alpha: 0.5),
shape: const RoundedRectangleBorder(
borderRadius:
BorderRadius.all(Radius.circular(32))),
Expand Down
3 changes: 1 addition & 2 deletions app/lib/dialogs/packs/select.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:butterfly_api/butterfly_api.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand All @@ -24,7 +23,7 @@ class SelectPackAssetDialog extends StatelessWidget {
List<PackAssetLocation> _getAssets(NoteData document) => document
.getPacks()
.map((e) => document.getPack(e))
.whereNotNull()
.nonNulls
.expand((pack) => switch (type) {
PackAssetType.component => pack.getComponents(),
PackAssetType.style => pack.getStyles(),
Expand Down
3 changes: 3 additions & 0 deletions app/lib/dialogs/packs/styles/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class _TextStyleViewState extends State<TextStyleView> {
widget.onChanged(widget.value.copyWith(color: null))),
defaultColor: null,
onChanged: (color) =>
// ignore: deprecated_member_use
widget.onChanged(widget.value.copyWith(color: color.value))),
ColorField(
title: Text(AppLocalizations.of(context).background),
Expand All @@ -72,6 +73,7 @@ class _TextStyleViewState extends State<TextStyleView> {
widget.value.copyWith(backgroundColor: null))),
defaultColor: null,
onChanged: (color) => widget.onChanged(
// ignore: deprecated_member_use
widget.value.copyWith(backgroundColor: color.value))),
ExactSlider(
header: Text(AppLocalizations.of(context).size),
Expand Down Expand Up @@ -216,6 +218,7 @@ class _TextStyleViewState extends State<TextStyleView> {
.copyWith(decorationColor: null))),
defaultColor: null,
onChanged: (color) => widget.onChanged(widget.value
// ignore: deprecated_member_use
.copyWith(decorationColor: color.value))),
Padding(
padding: const EdgeInsets.all(16.0),
Expand Down
3 changes: 3 additions & 0 deletions app/lib/dialogs/texture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class _TextureViewState extends State<TextureView> {
title: Text(AppLocalizations.of(context).color),
value: Color(widget.value.boxColor),
onChanged: (value) =>
// ignore: deprecated_member_use
widget.onChanged(widget.value.copyWith(boxColor: value.value)),
),
const SizedBox(height: 16),
Expand All @@ -60,6 +61,7 @@ class _TextureViewState extends State<TextureView> {
value: Color(widget.value.boxXColor),
title: Text(AppLocalizations.of(context).color),
onChanged: (value) => widget
// ignore: deprecated_member_use
.onChanged(widget.value.copyWith(boxXColor: value.value)),
),
const SizedBox(height: 16),
Expand Down Expand Up @@ -99,6 +101,7 @@ class _TextureViewState extends State<TextureView> {
title: Text(AppLocalizations.of(context).color),
value: Color(widget.value.boxYColor),
onChanged: (value) => widget
// ignore: deprecated_member_use
.onChanged(widget.value.copyWith(boxYColor: value.value)),
),
const SizedBox(height: 16),
Expand Down
6 changes: 4 additions & 2 deletions app/lib/handlers/area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AreaHandler extends Handler<AreaTool> {
...[
_currentArea,
...page.areas.where((element) => element.name != _currentArea?.name)
].whereNotNull().map((e) => AreaForegroundRenderer(e))
].nonNulls.map((e) => AreaForegroundRenderer(e))
],
_selectionManager.renderer,
];
Expand Down Expand Up @@ -82,7 +82,9 @@ class AreaHandler extends Handler<AreaTool> {
bool onScaleStart(ScaleStartDetails details, EventContext context) {
final currentIndex = context.getCurrentIndex();
if (currentIndex.buttons == kSecondaryMouseButton &&
currentIndex.temporaryHandler == null) return true;
currentIndex.temporaryHandler == null) {
return true;
}
final transform = context.getCameraTransform();
final globalPos = transform.localToGlobal(details.localFocalPoint);
if (_selectionManager.isValid) {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/handlers/import.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ImportHandler extends Handler<ImportTool> {
state.page,
))
.map((e) => e.transform(position: _offset, relative: true)?.element)
.whereNotNull()
.nonNulls
.toList()));
context
.getCurrentIndexCubit()
Expand Down
8 changes: 4 additions & 4 deletions app/lib/handlers/laser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ class LaserHandler extends Handler<LaserTool> with ColoredHandler {
return element.copyWith(points: subPoints);
}
var color = Color(data.color);
final toolOpacity = color.opacity;
final toolOpacity = color.a;
final opacity = (1 - delta) * toolOpacity;
color = color.withOpacity(opacity.clamp(0, 1));
color = color.withValues(alpha: opacity.clamp(0, 1));
return element.copyWith(
// ignore: deprecated_member_use
property: element.property.copyWith(color: color.value),
);
}
Expand Down Expand Up @@ -88,8 +89,7 @@ class LaserHandler extends Handler<LaserTool> with ColoredHandler {
}

void _submit(DocumentBloc bloc, List<int> indexes) {
final elements =
indexes.map((e) => _elements.remove(e)).whereNotNull().toList();
final elements = indexes.map((e) => _elements.remove(e)).nonNulls.toList();
if (elements.isEmpty) return;
_submittedElements.addAll(elements);
bloc.refresh();
Expand Down
2 changes: 1 addition & 1 deletion app/lib/handlers/path_eraser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PathEraserHandler extends Handler<PathEraserTool> {
final page = state?.page;
if (page == null) return;
if (!data.eraseElements) ray = ray.where((e) => e.element.isStroke());
var ids = ray.map((e) => e.element.id).whereNotNull();
var ids = ray.map((e) => e.element.id).nonNulls;
_erased.addAll(ids);
_currentlyErasing = false;
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/handlers/pen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PenHandler extends Handler<PenTool> with ColoredHandler {
// Submit elements for processing and rendering.
Future<void> submitElements(DocumentBloc bloc, List<int> indexes) async {
final elements =
indexes.map((e) => this.elements.remove(e)).whereNotNull().toList();
indexes.map((e) => this.elements.remove(e)).nonNulls.toList();
if (elements.isEmpty) return;
lastPosition.removeWhere((key, value) => indexes.contains(key));
bloc.add(ElementsCreated(elements));
Expand Down
8 changes: 4 additions & 4 deletions app/lib/handlers/select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SelectHandler extends Handler<SelectTool> {
changed = true;
return renderer;
})
.whereNotNull()
.nonNulls
.toList();
_updateSelectionRect();
return changed;
Expand Down Expand Up @@ -149,7 +149,7 @@ class SelectHandler extends Handler<SelectTool> {
final id = _selected[i].element.id;
if (id == null) return null;
return MapEntry(id, [e.element]);
}).whereNotNull())));
}).nonNulls)));
if (_duplicate) {
return _selected;
}
Expand Down Expand Up @@ -446,7 +446,7 @@ class SelectHandler extends Handler<SelectTool> {
if (state is! DocumentLoadSuccess) return;
if (cut) {
bloc.add(ElementsRemoved(
_selected.map((r) => r.element.id).whereNotNull().toList()));
_selected.map((r) => r.element.id).nonNulls.toList()));
}
final point = getSelectionRect()?.topLeft;
if (point == null) return;
Expand Down Expand Up @@ -498,7 +498,7 @@ class SelectHandler extends Handler<SelectTool> {
final state = bloc.state;
if (state is! DocumentLoadSuccess) return null;
context.read<DocumentBloc>().add(ElementsRemoved(
_selected.map((r) => r.element.id).whereNotNull().toList()));
_selected.map((r) => r.element.id).nonNulls.toList()));
_selected.clear();
bloc.refresh();
return null;
Expand Down
2 changes: 1 addition & 1 deletion app/lib/handlers/spacer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SpacerHandler extends Handler<SpacerTool> {
);
},
)
.whereNotNull()
.nonNulls
.toList() ??
[]);
_startPosition = null;
Expand Down
2 changes: 2 additions & 0 deletions app/lib/renderers/cursors/label.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: deprecated_member_use

import 'package:butterfly/cubits/transform.dart';
import 'package:butterfly_api/butterfly_api.dart';
import 'package:flutter/material.dart';
Expand Down
4 changes: 2 additions & 2 deletions app/lib/renderers/foregrounds/area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class AreaForegroundRenderer extends Renderer<Area> {
..color = colorScheme?.primary ?? Colors.blue;
var backgroundPaint = Paint()
..style = PaintingStyle.fill
..color =
(colorScheme?.primaryContainer ?? Colors.lightBlue).withOpacity(0.2);
..color = (colorScheme?.primaryContainer ?? Colors.lightBlue)
.withValues(alpha: 0.2);
canvas.drawRRect(
RRect.fromRectAndRadius(rect, Radius.circular(5 / transform.size)),
paint);
Expand Down
2 changes: 1 addition & 1 deletion app/lib/renderers/foregrounds/select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LassoSelectionForegroundRenderer extends Renderer<List<Offset>> {
..strokeJoin = StrokeJoin.round
..isAntiAlias = true;
final fillPaint = Paint()
..color = scheme.primaryContainer.withOpacity(0.2)
..color = scheme.primaryContainer.withValues(alpha: 0.2)
..style = PaintingStyle.fill;
final path = Path();
path.addPolygon(element, true);
Expand Down
7 changes: 3 additions & 4 deletions app/lib/selections/elements/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ class ElementSelection<T extends PadElement> extends Selection<Renderer<T>> {
update(context, renderers);
}

Rect? get rect =>
_expandRects(selected.map((e) => e.rect).whereNotNull().toList());
Rect? get rect => _expandRects(selected.map((e) => e.rect).nonNulls.toList());

Rect? get expandedRect =>
_expandRects(selected.map((e) => e.expandedRect).whereNotNull().toList());
_expandRects(selected.map((e) => e.expandedRect).nonNulls.toList());

Rect? _expandRects(List<Rect> rects) {
var rect = rects.firstOrNull;
Expand All @@ -130,7 +129,7 @@ class ElementSelection<T extends PadElement> extends Selection<Renderer<T>> {
final bloc = context.read<DocumentBloc>();
final state = bloc.state;
if (state is! DocumentLoadSuccess) return;
final ids = selected.map((r) => r.element.id).whereNotNull().toList();
final ids = selected.map((r) => r.element.id).nonNulls.toList();
context.read<DocumentBloc>().add(ElementsRemoved(ids));
}

Expand Down
1 change: 1 addition & 0 deletions app/lib/selections/elements/pen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class PenElementSelection extends ElementSelection<PenElement> {
context,
elements
.map((e) => e.copyWith(
// ignore: deprecated_member_use
property: e.property.copyWith(color: color.value)))
.toList()),
),
Expand Down
2 changes: 2 additions & 0 deletions app/lib/selections/elements/shape.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ class ShapeElementSelection extends ElementSelection<ShapeElement> {
context,
elements
.map((e) => e.copyWith(
// ignore: deprecated_member_use
property: e.property.copyWith(color: color.value)))
.toList()),
),
ExactSlider(
// ignore: deprecated_member_use
value: Color(element.property.color).alpha.toDouble(),
header: Text(AppLocalizations.of(context).alpha),
fractionDigits: 0,
Expand Down
2 changes: 2 additions & 0 deletions app/lib/selections/properties/pen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class PenPropertySelection extends PropertySelection<PenProperty>
ColorField(
value: Color(property.color),
onChanged: (value) =>
// ignore: deprecated_member_use
onChanged(property.copyWith(color: value.value)),
title: Text(AppLocalizations.of(context).color),
),
ExactSlider(
// ignore: deprecated_member_use
value: Color(property.color).alpha.toDouble(),
header: Text(AppLocalizations.of(context).alpha),
fractionDigits: 0,
Expand Down
Loading

0 comments on commit 8dc1189

Please sign in to comment.