-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TW-688 Web avoid frezze when uploading file
- Loading branch information
1 parent
58a0938
commit 7465cfa
Showing
6 changed files
with
81 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@JS() | ||
library window; | ||
|
||
import 'package:fluffychat/utils/js_window/universal_image_bitmap.dart'; | ||
import 'package:universal_html/html.dart'; | ||
import 'dart:typed_data'; | ||
|
||
import 'package:js/js.dart'; | ||
import 'package:js/js_util.dart'; | ||
|
||
@JS() | ||
@staticInterop | ||
class JSWindow {} | ||
|
||
extension JSWindowExtension on JSWindow { | ||
external Function get createImageBitmap; | ||
} | ||
|
||
JSWindow get jsWindow => window as JSWindow; | ||
|
||
Future<UniversalImageBitmap?> convertUint8ListToBitmap(Uint8List buffer) async { | ||
final blob = Blob([buffer]); | ||
|
||
final result = await jsWindow.createImageBitmap(blob); | ||
final ImageBitmap bitmap = await promiseToFuture(result); | ||
|
||
return UniversalImageBitmap(width: bitmap.width, height: bitmap.height); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'dart:typed_data'; | ||
|
||
import 'package:fluffychat/utils/js_window/universal_image_bitmap.dart'; | ||
|
||
Future<UniversalImageBitmap?> convertUint8ListToBitmap(Uint8List buffer) async { | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class UniversalImageBitmap { | ||
int? height; | ||
int? width; | ||
UniversalImageBitmap({ | ||
this.height, | ||
this.width, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters