flutter-web

How to import platform specific dependency in Flutter/Dart? (Combine Web with Android/iOS)

我是研究僧i 提交于 2019-12-07 23:41:54
问题 I am using shared_preferences in my Flutter application for iOS and Android. On the web I am using the http:dart dependency ( window.localStorage ) itself. Since Flutter for web was merged into the Flutter repo, I want to create a cross platform solution. This means I need to import two seperate API's. This seems not to be very good supported in Dart yet, but this is what I did: import 'package:some_project/stub/preference_utils_stub.dart' if (dart.library.html) 'dart:html' if (dart.library

How to change Flutter for web Font?

你说的曾经没有我的故事 提交于 2019-12-07 21:38:25
问题 I am trying to change the font of the title in my Flutter for Web Application how can i do it? I found out that the pubsec.yaml is completely different than the mobile version here is the file: name: projectbaseclient description: An app built using Flutter for web environment: # You must be using Flutter >=1.5.0 or Dart >=2.3.0 sdk: '>=2.3.0 <3.0.0' dependencies: flutter_web: any flutter_web_ui: any dev_dependencies: build_runner: ^1.5.0 build_web_compilers: ^2.1.0 pedantic: ^1.7.0

Is there any plugin or way to upload file to server using flutter web?

南楼画角 提交于 2019-12-07 03:29:03
问题 I want to upload image to the server from flutter web application. Is there any better way of doing that. I've already tried with couple of plugins. image-picker, file-picker But none of them are supported for flutter web. 回答1: you can use the FileUploadInputElement class of dart:html. The first thing to do is to import dart:html. import 'dart:html'; Implement following code to start a file picker: _startFilePicker() async { InputElement uploadInput = FileUploadInputElement(); uploadInput

How to import platform specific dependency in Flutter/Dart? (Combine Web with Android/iOS)

那年仲夏 提交于 2019-12-06 13:45:26
I am using shared_preferences in my Flutter application for iOS and Android. On the web I am using the http:dart dependency ( window.localStorage ) itself. Since Flutter for web was merged into the Flutter repo, I want to create a cross platform solution. This means I need to import two seperate API's. This seems not to be very good supported in Dart yet, but this is what I did: import 'package:some_project/stub/preference_utils_stub.dart' if (dart.library.html) 'dart:html' if (dart.library.io) 'package:shared_preferences/shared_preferences.dart'; In my preference_utils_stub.dart file, I

How to change Flutter for web Font?

不打扰是莪最后的温柔 提交于 2019-12-06 07:15:23
I am trying to change the font of the title in my Flutter for Web Application how can i do it? I found out that the pubsec.yaml is completely different than the mobile version here is the file: name: projectbaseclient description: An app built using Flutter for web environment: # You must be using Flutter >=1.5.0 or Dart >=2.3.0 sdk: '>=2.3.0 <3.0.0' dependencies: flutter_web: any flutter_web_ui: any dev_dependencies: build_runner: ^1.5.0 build_web_compilers: ^2.1.0 pedantic: ^1.7.0 dependency_overrides: flutter_web: git: url: https://github.com/flutter/flutter_web path: packages/flutter_web

Which map solution / package to use with Flutter Web?

吃可爱长大的小学妹 提交于 2019-12-04 12:34:48
I am porting over a flutter mobile project to flutter web and was curious which map package to use in place of: https://pub.dev/packages/google_maps_flutter I was able to get a workable solution, but it isn't pretty. Below is the implementation. If I get some time and a legit port doesn't come a long I will post an example repo. import 'dart:html'; import 'package:flutter_web/material.dart'; import 'package:lift_ai/base/screen_state.dart'; import 'package:lift_ai/feature/property_common/property_contract.dart'; import 'package:lift_ai/feature/property_common/property_presenter_impl.dart';

How to save to web local storage in flutter web

喜你入骨 提交于 2019-12-04 04:56:57
I have a web site built with flutter for web and currently, am trying to save to web local storage or cookie but can't seem to find any plugin or way to archive that. You can use window.localStorage from dart:html import 'dart:html'; class IdRepository { final Storage _localStorage = window.localStorage; Future save(String id) async { _localStorage['selected_id'] = id; } Future<String> getId() async => _localStorage['selected_id']; Future invalidate() async { _localStorage.remove('selected_id'); } } With flutter 1.10 we can use universal_html package: import 'package:universal_html/prefer

Error on retrieving assets for web (flutter)

安稳与你 提交于 2019-12-02 18:32:03
问题 I face an issue for Flutter WEB. I followed tutorial on assets from Flutter team (https://flutter.dev/docs/development/ui/assets-and-images) however I receive an error ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════ The following assertion was thrown resolving an image codec: Unable to load asset: assets/images/my_custom_image.png When the exception was thrown, this was the stack: dart:sdk_internal 4602:11 throw_ load package:flutter_web/…

How to make HTTP Requests on Flutter For Web?

爷,独闯天下 提交于 2019-12-02 13:34:51
问题 I am building an application that executes HTTP requests to a NodeJS Server but when i execute an HTTP request the result is the following: Access to XMLHttpRequest at 'http://127.0.0.1:8000/' from origin 'http://127.0.0.1:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. and Uncaught (in promise) Error: XMLHttpRequest error. dart:sdk_internal 41864:30 get

Error on retrieving assets for web (flutter)

a 夏天 提交于 2019-12-02 10:03:43
I face an issue for Flutter WEB. I followed tutorial on assets from Flutter team ( https://flutter.dev/docs/development/ui/assets-and-images ) however I receive an error ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════ The following assertion was thrown resolving an image codec: Unable to load asset: assets/images/my_custom_image.png When the exception was thrown, this was the stack: dart:sdk_internal 4602:11 throw_ load package:flutter_web/…/services/asset_bundle.dart:220 dart:sdk_internal 25309:9 <fn> ... Image provider: AssetImage(bundle: