I'm developing an app in Flutter for iOS where the user can easily look-up a word using the built-in dictionaries.
I used SelectableText for text so that user could select a word and that toolbar options for the selected text could be displayed. Among the ToolbarOptions of SelectableText I see copy, cut, paste and selectAll but not lookUp nor share.
I didn't try yet, but I know that share is available through a flutter package called "share". How do I add a lookUp to the SelectableText's toolbar menu? Is there any package that I do not aware of or I should dive into native for this?
My current code:
SelectableText(
this.deck[index % this.deck.length].front,
style: kCardTextStyle,
toolbarOptions: ToolbarOptions(copy: true, /* share: ??? */))
Need to build an application having the Map feature built on top of the OpenLayers lib. This app was built by the native languages on both platforms (ios and android) and it works fine. Now, we want to migrate to the flutter to gain the benefits of the "code once" terminology. Flutter seems to be the best choice except the webview plugin developed by the Flutter team. It is not supporting the communication between dart and js :-(. Also going through some plugins in the community but no luck to find the suitable one. Someone have a good idea and please advise. Thank you so much!
i know it's too late but it may help to other.
Here is an example of communication from Javascript code to flutter.
In Flutter build your WebView like :
WebView(
initialUrl: url,
javascriptMode: JavascriptMode.unrestricted,
javascriptChannels: Set.from([
JavascriptChannel(
name: 'Print',
onMessageReceived: (JavascriptMessage message) {
//This is where you receive message from
//javascript code and handle in Flutter/Dart
//like here, the message is just being printed
//in Run/LogCat window of android studio
print(message.message);
})
]),
onWebViewCreated: (WebViewController w) {
webViewController = w;
},
)
and in Your HTMLfile:
<script type='text/javascript'>
Print.postMessage('Hello World being called from Javascript code');
</script>
When you run this code, you shall be able to see log "Hello World being called from Javascript code" in the LogCat/Run window of android studio
if u want to send msg from dart to js then here is your example:-
flutterWebviewPlugin.evalJavascript('var x = document.getElementsByClassName("layout__area--top"); x[0].style.opacity =0;');
I am creating a Flutter project in which, I have a piece of data (JSON) that I want to Import from and Export to a location the user wants to. In order to achieve this, I require a File Picker plugin in Flutter. Now, I searched the Dart Packages repository for "file picker" but didn't find one.
Is there a way to get a File Picker that looks like this:
or even this...
The first screenshot is preferable for me as it allows file selection from different sources (like Drive).
Also, since I want to Export the data, I might want a Folder Picker too. ;)
But, if there is any other alternative to Folder Picker. I'd be happy to know...
I've created a file_picker plugin some time ago in order to make it possible to pick (both on iOS and Android) absolute paths and then loaded it with Flutter.
You can check it here: https://pub.dev/packages/file_picker
I used file_picker library to pick files. you can use this for pick images as well.
Future getPdfAndUpload(int position) async {
File file = await FilePicker.getFile(
type: FileType.custom,
allowedExtensions: ['pdf','docx'], //here you can add any of extention what you need to pick
);
if(file != null) {
setState(() {
file1 = file; //file1 is a global variable which i created
});
}
}
here file_picker flutter library.
I'm in the exact same boat as you, haha!
I noticed documents_picker 0.0.2. It allows the user to pick multiple files, and it seems to fit the need!
check it out: https://pub.dartlang.org/packages/documents_picker#-readme-tab-
Here's a better document picker. It looks like the native document picker from the Storage Access Framework, which is what you have in your picture.
flutter_document_picker
Just found the FileSelector plugin from flutter.dev. Compatible with MacOS, Windows and Web.
From its pub.dev page:
Open a single file
final typeGroup = XTypeGroup(label: 'images', extensions: ['jpg', 'png']);
final file = await openFile(acceptedTypeGroups: [typeGroup]);
Open multiple files at once
final typeGroup = XTypeGroup(label: 'images', extensions: ['jpg', 'png']);
final files = await openFiles(acceptedTypeGroups: [typeGroup]);
Saving a file
final path = await getSavePath();
final name = "hello_file_selector.txt";
final data = Uint8List.fromList("Hello World!".codeUnits);
final mimeType = "text/plain";
final file = XFile.fromData(data, name: name, mimeType: mimeType);
await file.saveTo(path);
MacOS: Provide file read or/and write privileges
On target MacOS please provide sufficient rights using Xcode:
In case you don't provide file read or/and write permissions, the call to
final XFile? file =
await openFile(acceptedTypeGroups: <XTypeGroup>[typeGroup]);
neither shows anything not returns.
I tried adding an image with a SVG source to my flutter application.
new AssetImage("assets/images/candle.svg"))
But I didn't get any visual feedback.
How can I render an SVG picture in Flutter?
Fonts are a great option for a lot of cases.
I've been working on a library to render SVGs on a canvas, available here:
https://github.com/dnfield/flutter_svg
The API as of right now would look something like
new SvgPicture.asset('asset_name.svg')
to render asset_name.svg (sized to its parent, e.g. a SizedBox). You can also specify a color and blendMode for tinting the asset..
It's now available on pub and works with a minimum of Flutter version 0.3.6. It handles a bunch of cases but not everything - see the GitHub repo for updates and to file issues.
The original GitHub issue referenced by Colin Jackson is really not meant to be primarily focused on SVG in Flutter. I opened another issue here for that: https://github.com/flutter/flutter/issues/15501
Flutter does not currently support SVG. Follow issue 1831 for updates.
If you absolutely need vector drawing you can see the Flutter Logo widget as an example of how to draw using the Canvas API, or rasterize your image on the native side and pass it to Flutter as a bitmap, but for now your best bet is probably to embed high-resolution rasterized asset images.
Developers from the Flutter community created a lib to handle svg files. We can use it as
new SvgPicture.asset(
'assets/images/candle.svg',
height: 20.0,
width: 20.0,
allowDrawingOutsideViewBox: true,
),
I found a small example of SVG implementation here.
The work around for now is use fonts
https://icomoon.io/
fonts:
- family: icomoon
fonts:
- asset: assets/fonts/icomoon.ttf
Useage
static const IconData TabBarHome= const IconData(0xe906, fontFamily: 'icomoon');
static const IconData TabBarExplore= const IconData(0xe902, fontFamily: 'icomoon');
Replace the ### eg (906)
You can follow the below steps
- visit http://fluttericon.com
- upload your SVG icons
- click on download button
- you will get two files
1. iconname.dart 2. iconname.ttf font file
- use this file in flutter & import iconname.dart
step 1. add dependency in your pubspec.yaml
dependencies:
flutter_svg: any
the Advantage of version any is you can use in any SDK version
but dependencies version is most important so add suitable version for your dependency.
step 2. import the flutter svg package in your app
import 'package:flutter_svg/flutter_svg.dart';
step 3. just use like below
SvgPicture.asset(
'assets/images/bm-icon1.svg',
width: 18.0,
height: 18.0,
),
You can use this library for rendering SVG Images - https://pub.dev/packages/flutter_svg
Example -
Container(
child: SvgPicture.asset("assets/images/yourImage.svg")
)
I solved similar problem by converting the svg images to ttf at fluttericon.com.
These are the steps involved.
Keep all your svg files in a folder.
Upload all of them to fluttericon by using the uploader there.
You can select all of them and drag and drop at the spot.
Give your icons a dart class name at the top: like, Svgicons
Select all your icons and press Download.
It will download a zip file with a dart file and fonts folder which contains Svgicons.ttf.
copy the fonts folder to your project folder and refer to it as an asset in pubspec.yaml.
fonts:
- family: Svgicons
fonts:
- asset: fonts/Svgicons.ttf
import the svgicons_icons.dart where you are going to use the images.
Sample:
import '../svgicons_icons.dart';
import 'social_media.dart';
class SocialMediaRepository {
List<SocialMedia> getSocialMedia = [
SocialMedia(id: 1, title: "Facebook", iconAsset:Svgicons.facebook, isFavorite: false),
SocialMedia(id: 2, title: "Instagram", iconAsset: Svgicons.instagram, isFavorite: false),
SocialMedia(id: 3, title: "LinkedIn", iconAsset: Svgicons.linkedin, isFavorite: false),
....
Here iconAsset is of type IconData which used to be a String referring to the svg image originally.
Display the ttf by using
...
Icon(item.iconAsset),
SizedBox(width: 10),
Text(item.title),
],
),
where item is the object containing IconData.
Now you can remove the reference to svg images from the project.
You can use flare to create animations and just import .flr as an asset
import 'package:flare_flutter/flare_actor.dart';
class MyHomePage extends StatefulWidget {
#override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return new FlareActor("assets/Filip.flr", alignment:Alignment.center, fit:BoxFit.contain, animation:"idle");
}
}
visit flare_flutter https://pub.dev/packages/flare_flutter
Of possible interest: There's a newer Flutter SVG library called jovial_svg. I wrote it to handle a more robust subset of SVG than what I was able to find on pub.dev at the time. While I was at it, I also made a binary format that SVG assets can be compiled to. It's a little more compact, and about 10x faster to read, so it's a good choice for assets you package with your application.
The library is at https://pub.dev/packages/jovial_svg
flutter support special type of svg
if have style tag then not load svg image in flutter
flutter support inline styling in svg
Svg in flutter https://pub.dev/packages/flutter_svg
add package in pubspec.yaml
dependencies:
flutter_svg: any
assets:
-assets/images/
to insert svg.
SvgPicture.asset('assets/images/password-icon.svg',
width: 24, height: 29.2),
In my Unity3D application for iOS I want to share some info in Facebook. So I have used FB.ShareLink() method in this situation.
But when it shows Share dialog there are two buttons Cancel at the left side and Share at the right side, also there is a title with "Share" text.
How can I delete or hide that "Share" title in the middle of the window?
public override void ShareLink(
Uri contentURL,
string contentTitle,
string contentDescription,
Uri photoURL,
FacebookDelegate<IShareResult> callback)
{
MethodArguments args = new MethodArguments();
args.AddUri("content_url", contentURL);
args.AddString("content_title", contentTitle);
args.AddString("content_description", contentDescription);
args.AddUri("photo_url", photoURL);
var shareLinkCall = new JavaMethodCall<IShareResult>(this, "ShareLink");
shareLinkCall.Callback = callback;
shareLinkCall.Call(args);
}
This is the code that Facebook use for sharing on Android in Facebook Unity SDK. As I see, there is no way to modify share gui from unity plugin, because all of this processes are completed in java classes.
Edit: For editing an external .jar file look at this topic:
I have an external executable jar file that I wish to edit the java files in it with Eclipse