Android Studio not showing Flutter Source Code - android-studio

I'm trying to get access to the source of code of a widget however Android Studio is not showing the correct source code as I cannot see the build method that builds that widget. See below:
This is the widget I'm trying to get access to the source code by using CTRL+clicking on the widget
FloatingActionButton(
backgroundColor: Colors.grey,
child: Icon(Icons.email),
),
However I get transfered to this nonesense code with errors, any advise how can I fix this?

Related

Load HTML file and display in Flutter Web

I have a single HTML file that contains some JS functions and CSS styling.
Is it possible to load my html file into an embedded widget on Flutter Web? I've successfully accomplished this on iOS and Android using the flutter_webview pacakge, but haven't found a solution for Flutter Web.
There is a HTMLElementView widget which can help you embed Html in flutter web. This widget can take an Iframe and render it. If you don't prefer Iframe then you can embed simply a BodyElement from the dart:html library directly.
An example of embedding Iframe is availabel here. Eventhough its from an old repo, the code is valid and I couldn't find a latest one.
If you don't want do go the tough way, there is simplified widget from Rodydavis which is available here called easy_web_view.
Still if you need code sample a create simple dart pad and share the MRE, I will try to help. :)
For the Iframe example, you can do something like this
First, import 'ui' library, and 'html' library.
import 'dart:ui' as ui;
import 'dart:html';
Second, register your 'Iframe' with viewType 'test-view-type' just for example.
ui.platformViewRegistry.registerViewFactory(
'test-view-type',
(int viewId) => IFrameElement()
..width = '640'
..height = '360'
..src = "https://www.youtube.com/embed/5VbAwhBBHsg"
..style.border = 'none');
Note: you will notice that the compiler can't find platformViewRegistry method but it's okay if you choose to Debug anyway and it will run correctly without any problems.
Finally, use HtmlElementView widget to run this Iframe
return Scaffold(
body: Column(
children: [
Text('Testing Iframe with Flutter'),
HtmlElementView(viewType: 'test-view-type'),
],
));
You can use this package flutter_widget_from_html
While defining the widget you need to set webView: true to get iFrame support
I just tested and it is working fine on web, and this package supports local assets too

Custom Appbar's animation Flutter

I want to make app bar with animation like this. Any ideas?
GIF
You can use SliverAppBar For the animation you want to create,
SliverAppBar(
expandedHeight: height,
flexibleSpace: const FlexibleSpaceBar(
title: Text('Reading Now'),
),
For more details you can visit here

Android Studio can't resolve resource drawable

I'm designing my layout, and I've exported many assets from Sketch. Everything's going fine, but on just one particular asset, I'm getting the following error:
The resource is there, included in the project, I can open it (a regular PNG) perfectly etc, and is no different from any other assets in any way.
When I click Details on the error above, I get:
java.lang.NumberFormatException: Color value '#drawable/comment_off' must start with #
at com.android.layoutlib.bridge.impl.ResourceHelper.getColor(ResourceHelper.java:79)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:270)
at android.content.res.BridgeTypedArray.getDrawable(BridgeTypedArray.java:729)
at android.widget.ImageView.<init>(ImageView.java:152)
at android.widget.ImageView.<init>(ImageView.java:140)
at android.widget.ImageView.<init>(ImageView.java:136)
...
Why on Earth does Android Studio think that my drawable is a color, while it's a PNG image like all the other assets in my project?
You may want to check the spelling of your drawable folder to ensure it is correct, and that the image exists at the referenced assets folder.

Relative layout id is not getting on tablet in android

I am making app for mobile ,7" tablet(600*1024) and 10" tablet(720*1280). I created the following folders for layout and drawable.
drawable-hdpi
drawable-land-hdpi
drawable-land-mdpi
drawable-large-mdpi
drawable-large-port-mdpi
drawable-ldpi
drwable-mdpi
layout
layout-sw600dp(7")
layout-sw720dp(10")
layout-land
layout-sw600dp-land(7")
layout-sw720dp-land(10")
It is working fine on mobile but not working in tablets.It is giving null pointer exception for relative layout on fist screen of the app.It is not picking relative layout from XML while using tablet.I am testing on emulator.Can anybody help me.
Thanks in advance
I was also facing same problem. RelativeLayout was id was null when I tested on tablet.
Problem was: By mistake I didn't added RelativeLayout in my layout xml corresponding to tablet, meaning large-layout.
Here in your case these (layout-sw600dp(7"), layout-sw720dp(10"), layout-sw600dp-land(7"), layout-sw720dp-land(10")) are folders related to large screens.
To resolve the issue I added RelativeLayout in corresponding xml file in large layout folders.
And it stopped throwing NPE for RelativeLayout when I tested it again for tablets.

How can I display an image as the background of griffon application?

I was trying using the CSSBuilder plugin but it seems that it does not support the CSS background image property.
I have been searching in google and it seems you can add background image to a swing panel by subclassing the panel. But I am pretty new to Swing and I do not know how to do it. I would like to know if there is an easier way to accomplish this with griffon.
Thanks in advanced.
Here's one possible to solution:
install the javatips plugin, i.e, griffon install-plugin javatips
Use the backgroundPanel() node
Here's a barebones example
package sample
import javax.imageio.ImageIO
application(title: 'Sample',
preferredSize: [320, 330],
pack: true) {
backgroundPanel(image: ImageIO.read(app.getResourceAsURL('griffon-icon-256x256.png')))
}

Resources