Download file from url, save to phones storage

Use https://pub.dartlang.org/packages/flutter_downloader. Don’t forget to do platform configurations. Basically, this is how you should use the package. There is a detailed long example in the link. final taskId = await FlutterDownloader.enqueue( url: ‘your download link’, savedDir: ‘the path of directory where you want to save downloaded files’, showNotification: true, // show download progress in status …

Read more

Everything expands to screenwidth inside a Listview. Can I change that?

You can use Align widget to align it’s child inside it’s parent. Simply wrap your list nodes (Card instances) inside a Align. import ‘package:flutter/material.dart’; //import ‘../../Library/Library.dart’; //import ‘../../Ui/ChatMessage.dart’; void main() { runApp( new MaterialApp( home: new ChatScreen(), ), ); } class ChatScreen extends StatefulWidget { @override State<StatefulWidget> createState() { return new ChatScreenState(); } } class …

Read more

How to get widget’s absolute coordinates on a screen in Flutter?

You can use this extension I wrote (requires Dart 2.6): extension GlobalKeyExtension on GlobalKey { Rect? get globalPaintBounds { final renderObject = currentContext?.findRenderObject(); final translation = renderObject?.getTransformTo(null).getTranslation(); if (translation != null && renderObject?.paintBounds != null) { final offset = Offset(translation.x, translation.y); return renderObject!.paintBounds.shift(offset); } else { return null; } } } Example how to use …

Read more

Always show scrollbar – Flutter

Updated Answer April 2023 As of v2.9.0-1.0.pre, isAlwaysShown is deprecated and you should use thumbVisibility instead. Check jayjw’s more complete answer: https://stackoverflow.com/a/71357052/9777674 Original Answer June 2020 As of Flutter version 1.17, on Scrollbar you can set isAlwaysShown to true, but you must set the same controller for your Scrollbar and your SingleChildScrollView (and that applies …

Read more

How to read and write a text file in Flutter

Setup Add the following plugin in pubspec.yaml: dependencies: path_provider: ^1.6.27 Update the version number to whatever is current. And import it in your code. import ‘package:path_provider/path_provider.dart’; You also have to import dart:io to use the File class. import ‘dart:io’; Writing to a text file _write(String text) async { final Directory directory = await getApplicationDocumentsDirectory(); final …

Read more

Flutter: ListView not scrollable, not bouncing

To always have the scroll enabled on a ListView you can wrap the original scroll phisics you want with the AlwaysScrollableScrollPhysics class. More details here. If you want you can specify a parent or rely on the default. Here is your example with the option added: import ‘package:flutter/material.dart’; void main() => runApp(new MyApp()); class MyApp …

Read more