Posts

Showing posts with the label flutter

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 add the widgets dynamically to column in Flutter?

Image
Clash Royale CLAN TAG #URR8PPP How to add the widgets dynamically to column in Flutter? I have added a few widgets inside the ListView . So that I can scroll all widgets. Now I required to add one more widget to the ListView to load the list of comments. I can not add the ListView inside the ListView . And moreover, I do not require the separate scroll for my comments. It should be scroll along with the widgets inside the ListView . So I planned to add the Column instead of ListView . Could any help to add my comments dynamically in the Columns ? ListView ListView ListView ListView ListView Column ListView Columns new Expanded( child: new ListView( shrinkWrap: true, children: <Widget>[ // Title new Padding(padding: const EdgeInsets.only( top: 10.00, left: 10.00), child: new Text( _feed.title, textAlign: TextAlign.start,), ), ...

Flutter Unable to create directory (OS Error: Read-only file system)

Image
Clash Royale CLAN TAG #URR8PPP Flutter Unable to create directory (OS Error: Read-only file system) I was following - how to create directory from https://docs.flutter.io/flutter/dart-io/Directory-class.html new Directory('dir/subdir').create(recursive: true) // The created directory is returned as a Future. .then((Directory directory) { print(directory.path); }); This is the error I am getting: FileSystemException: Creation failed, path = 'dir' (OS Error: Read-only file system, errno = 30) I have enabled Storage(WRITE_EXTERNAL_STORAGE) permission. (Android device) Storage(WRITE_EXTERNAL_STORAGE) What am I missing? Use pub.dartlang.org/packages/path_provider to get valid paths where you can read/write files. – Günter Zöchbauer 47 mins ago @GünterZöchbauer thanks. Flutter Docs are slightly...

Flutter TextField - how to shrink the font if the text entered overflows

Image
Clash Royale CLAN TAG #URR8PPP Flutter TextField - how to shrink the font if the text entered overflows I have a TextField (not a Text) widget that must remain on one line. I want to reduce it's font size if the text entered is too large for the TextField box, ie shrink it if it overflows. How can I do this? I have written some code like this in a stateful component if (textLength < 32) { newAutoTextVM.fontSize = 35.0; } else if (textLength < 42) { newAutoTextVM.fontSize = 25.0; In the view fontSize: 25.0, but it isn't very intelligent, it doesn't cope with resizing, also, because the font size isn't monospaced (courier etc), different characters take up different amounts of space. 1 Answer 1 I have searched through the docs and found a couple of solutions that could come at your help: Depending on the rest of your code one of these solutions could be better, try tweaking...

Flutter Firebase Auth

Image
Clash Royale CLAN TAG #URR8PPP Flutter Firebase Auth I'm developing flutter app and I added firebase auth to project. And it's running fine, but when app loads up console says this. Is this normal behavior? Thank you! 5.4.1 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. 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.

Stop how to stop the timer in flutter?

Image
Clash Royale CLAN TAG #URR8PPP Stop how to stop the timer in flutter? I have created a timer in flutter and everything works fine. Now I cant figure out how to dismiss the timer after I started it. The docs say that you can cancel it by calling "void cancel()" but I don't understand the implementation. How am I supposed to call it? And is it the right approach? static const timeout = const Duration(seconds: 5); static const ms = const Duration(milliseconds: 1); startTimeout([int milliseconds]) { var duration = milliseconds == null ? timeout : ms * milliseconds; return new Timer(duration, handleTimeout); } void handleTimeout() { // callback function Navigator.of(context).pushAndRemoveUntil(new MaterialPageRoute( builder: (BuildContext context) => new ScorePage(quiz.score, quiz.length)),(Route route) => route == null); return; } 1 Answer 1 Just...

Any package in flutter could compress pictures?

Image
Clash Royale CLAN TAG #URR8PPP Any package in flutter could compress pictures? I have try 'image_jpeg'.It works,but the pic rotates 90 degrees and turns into a square. Any other package could compress pictures? This kind of question is off-topic on StackOverflow. Please use other channels to ask for libraries, tutorials, and to find other references to external stuff. stackoverflow.com/help/on-topic – Günter Zöchbauer 6 mins ago 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.

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.

Flutter: login through a webview

Image
Clash Royale CLAN TAG #URR8PPP Flutter: login through a webview I'm pretty new to Flutter. Is there a way to login through a webview into our app? e.g. In the first page there is this webview where we can do the login. After we logged in, the app takes us in a second page where we can do other stuff. There are authentication packages that do that. You should be able to derive a custom solution from their source. I don't know which exactly but they should be in pub.dartlang.org. Perhaps facebook auth (not sure) – Günter Zöchbauer 3 hours ago 1 Answer 1 In my app I use instagram implicit authentification, which implies to login user in webview and get token from redirect url. I use flutter_webview_plugin Next code builds WebviewScaffold with login ...

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...