Posts

Showing posts with the label dart

convert a String of “uint8list” to a Unit8List

Image
Clash Royale CLAN TAG #URR8PPP convert a String of “uint8list” to a Unit8List I have a memory image stored in Sqllite converted to String with the toString() method, I want to convert it to Unit8List to display it inside a MemoryImage widget 1 Answer 1 codeUnits gets you a List<int> Uint8List.fromList(...) converts List<int> to Uint8List String.fromCharCodes(...) converts List<int> or Uint8List to String` codeUnits List<int> Uint8List.fromList(...) List<int> Uint8List String.fromCharCodes(...) List<int> or to List<int> list = 'xxx'.codeUnits; Uint8List bytes = Uint8List.fromList(list); String string = String.fromCharCodes(bytes); By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the ...

How to use rootBundle in flutter to load images?

Image
Clash Royale CLAN TAG #URR8PPP How to use rootBundle in flutter to load images? I use image plugin ( image: ^2.0.4 ) so I can write something on to the image and later save it new image to device or send via mail. I try to load image using " new File " but got error on Flutter. I ask and search and got a hint that I can use rootBundle to load image in Flutter. I did, and I got this below error. [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception: Unable to load asset: packages/myAppName/assets/images/ReceiptRaw_1.jpg The plugin works when I create a simple dart console app, but couldn't load using flutter. Any help please, This is the Flutter Code: Future<bool> makeReceiptImage() async { // UPDATE **************************************** // load the receipt jpeg var imageData = await rootBundle.load('packages/myAppName/dekonts/ReceiptRaw_1.jpg'); print("imageData: $imageData"); // Prints as imageData: Instance of...

How to draw a custom rounded rectangle border (ShapeBorder), in Flutter?

Image
Clash Royale CLAN TAG #URR8PPP How to draw a custom rounded rectangle border (ShapeBorder), in Flutter? I'm trying to extend the ShapeBorder class to add some functionality. But just playing around with the paint method, I found something that I did not expect: ShapeBorder paint The corners of the border and the corners of the rectangle do not seem to match. I used the following code: class CustomRoundedRectangleBorder extends ShapeBorder { final double borderWidth; final BorderRadius borderRadius; const CustomRoundedRectangleBorder({ this.borderWidth: 1.0, this.borderRadius: BorderRadius.zero, }) : assert(borderRadius != null); @override EdgeInsetsGeometry get dimensions { return new EdgeInsets.all(borderWidth); } @override ShapeBorder scale(double t) { return new CustomRoundedRectangleBorder( borderWidth: borderWidth * (t), borderRadius: borderRadius * (t), ); } @override ShapeBorder lerpFrom(ShapeBorder a, double t)...

Flutter: how to select all data of an API/JSON in a parameter in uri.http for a uri in fluttert

Image
Clash Royale CLAN TAG #URR8PPP Flutter: how to select all data of an API/JSON in a parameter in uri.http for a uri in fluttert The Uri http is var uri = new Uri.http('link', 'path', {'paramaterid': '1', 'parametercitydescription': 'where the select all begins'}); Thanks in Advance By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Doing something when a widget leaves the screen

Image
Clash Royale CLAN TAG #URR8PPP Doing something when a widget leaves the screen Suppose, I have a StatefulWidget, which periodically requests data from a server and this updates its state. I prepared a Timer.periodic() to make the data get loaded off the main loop. Timer.periodic() Now, if the widget leaves the screen, the Timer continues to call its callback. What is the correct mount point to perform cleanup actions, when the widget get off the screen? 1 Answer 1 @override void dispose() { super.dispose(); ... } You could also skip updates while mounted == false mounted == false See Flutter docs. unmount() isn't defined in StatefulWidget. – SteAp 12 mins ago Just d...