How to Pick files and Images for upload with flutter web

Using dart:html package directly in Flutter is not recommended. Instead, use this package: https://pub.dev/packages/file_picker. Example of how to use in Flutter Web: class FileUploadButton extends StatelessWidget { @override Widget build(BuildContext context) { return RaisedButton( child: Text(‘UPLOAD FILE’), onPressed: () async { var picked = await FilePicker.platform.pickFiles(); if (picked != null) { print(picked.files.first.name); } }, ); … Read more

How do I build different versions of my Flutter app for qa/dev/prod?

Building on Seth’s idea, here’s an example that sets up a global representing the BuildEnvironment named env. env.dart import ‘package:meta/meta.dart’; enum BuildFlavor { production, development, staging } BuildEnvironment get env => _env; BuildEnvironment _env; class BuildEnvironment { /// The backend server. final String baseUrl; final BuildFlavor flavor; BuildEnvironment._init({this.flavor, this.baseUrl}); /// Sets up the top-level [env] … Read more

Async/Await feature in Dart 1.8

Update 2 The most recent nightly build also supports async* void main() { generate().listen((i) => print(i)); } Stream<int> generate () async* { int i = 0; for(int i = 0; i < 100; i++) { yield ++i; } } Update yield and yield* in a method marked sync* (returning an Iterable) are already supported in … Read more

forEach vs for in: Different Behavior When Calling a Method

Although there is a prefer_foreach lint, that recommendation is specifically for cases where you can use it with a tear-off (a reference to an existing function). Effective Dart recommends against using Iterable.forEach with anything else, and there is a corresponding avoid_function_literals_in_foreach_calls lint to enforce it. Except for those simple cases where the callback is a … Read more

Flutter Load Image from Firebase Storage

To view the images inside your storage, what you need is the name of the file in the storage. Once you’ve the file name for the specific image you need. In my case if i want the testimage to be loaded, final ref = FirebaseStorage.instance.ref().child(‘testimage’); // no need of the file extension, the name will … Read more

When I select a Textfield the keyboard moves over it

Compose an animation and move your TextField container up when a TextField gets focus. For learning about composing animations refer to: Composing Animations and Chaining Animations in Dart’s Flutter Framework Use Flutter’s FocusNode to detect the focus on a TextField Edit: Here I’ve written an example that does exactly what you want: import ‘package:flutter/material.dart’; void … Read more

how can we use superscript and subscript text in flutter Text or RichText

You need to use Unicode. Here is the Unicode got from this answer: unicode_map = { # superscript subscript ‘0’ : (‘\u2070’, ‘\u2080’ ), ‘1’ : (‘\u00B9’, ‘\u2081’ ), ‘2’ : (‘\u00B2’, ‘\u2082’ ), ‘3’ : (‘\u00B3’, ‘\u2083’ ), ‘4’ : (‘\u2074’, ‘\u2084’ ), ‘5’ : (‘\u2075’, ‘\u2085’ ), ‘6’ : (‘\u2076’, ‘\u2086’ ), ‘7’ … Read more