Skip to content

Commit

Permalink
Migrate to web package
Browse files Browse the repository at this point in the history
This introduces full WASM support for PowaSys Frontend - now only intl needs to properly support it
  • Loading branch information
ThexXTURBOXx committed Aug 11, 2024
1 parent 1cdf0c4 commit b1fe24e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/bloc/cubits/export_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:convert';
import 'dart:html';

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:powasys_frontend/bloc/repos/data_repo.dart';
Expand All @@ -8,6 +7,7 @@ import 'package:powasys_frontend/constants.dart';
import 'package:powasys_frontend/data/trend.dart';
import 'package:powasys_frontend/generated/l10n.dart';
import 'package:tuple/tuple.dart';
import 'package:web/web.dart';

class ExportCubit extends Cubit<ExportState> {
ExportCubit(this._dataRepo)
Expand Down Expand Up @@ -66,13 +66,13 @@ class ExportCubit extends Cubit<ExportState> {
"${e.item3[Trend.temperature]}\n",
).join()}';

final elem = document.createElement('anchor') as HTMLAnchorElement
..href = 'data:application/octet-stream;charset=utf-16le;base64,'
'${base64Encode(toExport.codeUnits)}';
emit(
state.copyWith(
state: ExportGenState.exported,
toDownload: AnchorElement(
href: 'data:application/octet-stream;charset=utf-16le;base64,'
'${base64Encode(toExport.codeUnits)}',
),
toDownload: elem,
),
);
} catch (e) {
Expand Down
7 changes: 3 additions & 4 deletions lib/bloc/states.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'dart:html';

import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
import 'package:powasys_frontend/data/trend.dart';
import 'package:tuple/tuple.dart';
import 'package:web/web.dart';

class BlocState<State> {
const BlocState(
Expand Down Expand Up @@ -82,12 +81,12 @@ class ExportState extends BlocState<ExportGenState> {
this.toDownload,
});

final AnchorElement? toDownload;
final HTMLAnchorElement? toDownload;

ExportState copyWith({
ExportGenState? state,
ex,
AnchorElement? toDownload,
HTMLAnchorElement? toDownload,
}) =>
ExportState(
state ?? super.state,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ packages:
source: hosted
version: "2.1.4"
web:
dependency: transitive
dependency: "direct main"
description:
name: web
sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies:
package_info_plus: ^8.0.0
sprintf: ^7.0.0
tuple: ^2.0.0
web: ^1.0.0

dev_dependencies:
flutter_lints: ^4.0.0
Expand Down

0 comments on commit b1fe24e

Please sign in to comment.