Ever since I updated Flutter for Android Studio, I have been getting this fatal crash everytime I try to run a hot reload:
Initializing hot reload...
I/flutter (20514): [INFO:engine.cc(582)] Could not configure asset bundle at path: /data/user/0/com.natech.flutterlaunch/cache/flutter_launchZTLJVC/flutter_launch/build/flutter_assets
D/MALI (20514): osup_destructor:170: osup_destructor
Lost connection to device.
After this error, my code changes do not bother reflecting on the app even when I run a full restart. Even if I remove all the widgets from the screen in hope it shows a blank space, the app remains the same. Here is my code:
class SplashScreen extends StatelessWidget{
#override
Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(
image: splashBackgroundImage
),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Container(
width: 200.0,
height: 200.0,
alignment: Alignment.center,
decoration: new BoxDecoration(
image: logoImage
),
)
,/*new CircularProgressIndicator(
value: null,
strokeWidth: 1.0,
valueColor: new AlwaysStoppedAnimation<Color>(
Colors.blue
),
)*/
],
),
);
}
}
As you can see I commented out the CircularProgressIndicator but it still shows on the app even after a full restart. Anyone know what might be the issue?
This is very likely due to tracking the master branch, which has had a little instability in the last week or so around hot reloading and asset bundles.
You can try doing a flutter upgrade to see if the latest work in master will resolve your issues; it's more likely that you should be tracking beta (flutter channel beta) instead (or deal with hot reload not working until some more things are ironed out in master).
Related
Update 2: created a new app with just the demo and it also doesn’t work on work computer except Firefox. Tried setting alerts throughout the index.html service_worker and they seem to trigger. The app that does work is older, so maybe something broken in the newer versions?
Update: I copied the working button into the non working one and it doesn’t work. So something about the entire web app doesn’t seem to work, not just the button.
Can someone suggest next steps to diagnose this issue? At home, everything works, so I'm assuming the issue lies in the workplace firewall (just a guess).
I'm using a simple TextButton, and on Firefox it works just fine (hover effect shows, and clicking does what it's supposed to).
However, in Chrome, Explorer, and Edge hovering over the button shows no hover effect, and clicking does nothing.
Unfortunately, the inspector is disabled at work, so I can't try and see what's going on, though that's limited anyway based on how Flutter draws out the app.
Interestingly (and perhaps helpfully), I have a second Flutter web app with a TextButton that does seem to work in all browsers at work. Here are the two buttons:
Working in all browsers:
TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(EdgeInsets.all(20)),
foregroundColor: MaterialStateProperty.all<Color>(Colors.blue),
overlayColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.hovered))
return Colors.blue.withOpacity(0.8);
if (states.contains(MaterialState.focused) ||
states.contains(MaterialState.pressed))
return Colors.blue.withOpacity(0.12);
return null; // Defer to the widget's default.
},
),
),
child: new Text("Button Text", style: TextStyle(color: Colors.white)),
onPressed: () {
setState(() {
Navigator.pushNamed(context, '/route');
});
},
),
Working only in Firefox:
TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(EdgeInsets.all(20)),
foregroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.hovered))
return colorButtonTextHovered;
if (states.contains(MaterialState.focused) ||
states.contains(MaterialState.pressed))
return colorButtonTextFocusPress;
return colorButtonTextDefault;
},
),
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.hovered))
return colorButtonBackgroundHovered;
if (states.contains(MaterialState.focused) ||
states.contains(MaterialState.pressed))
return colorButtonBackgroundFocusPress;
return colorButtonBackgroundDefault;
},
),
),
child: new Text("Button Text"),
onPressed: () {
setState(() {
Navigator.push(
context,
FadeRoute(
MyApp.mtAppKey,
'/route',
),
);
});
},
),
Any tips, suggestions, next steps to diagnosing and fixing this issue?
how to extract all the relations between classes from a flutter file?
for example, in the below code, The desired output should be
1- I have widget RotationTransition
2- RotationTransition has one child of type Stack
3- Stack has children (Positioned, Center)
4- Positioned has a child of type FlutterLogo
5- Center has one child of type FlutterLogo
(It would be better if it's represented in tree form :D) any ideas How can I get such output?
RotationTransition(
turns: animation,
child: Stack(
children: [
Positioned.fill(
child: FlutterLogo(),
),
Center(
child: Text(
'Click me!',
style: TextStyle(
fontSize: 60.0,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
You can use Dart DevTools. It provides all the widget tree like below.
You can use dart tools if you are using VSCode
click on this icon to open dart
and than this will open
here all the widgets will be shown in tree form with there details too
I want to ask about the "Format Document" feature, why when using the "document format" feature in VScode, the tabulation becomes irregular like the code that I attached below.
I have tried to set "Editor: tab size" to 2 but when I use "Format Document", my code becomes irregular.
#override
Widget build(BuildContext context) {
````return new Container(
````````child: new Column(
``````children: <Widget>[
````````new Row(
``````````children: <Widget>[
````````````//slideshow
````````````new Expanded(
````````````````child: new CarouselSlider(
``````````````height: 150.0,
I expect the code like this :
#override
``Widget build(BuildContext context) {
````return new Container(
``````child: new Column(
````````children: <Widget>[
``````````new Row(
````````````children: <Widget>[
``````````````//slideshow
``````````````new Expanded(
````````````````child: new CarouselSlider(
````````````````height: 150.0,
The formatting is done by dart_style/dartfmt, and its convention is 2-space indenting, with 4 spaces for continued lines.
For Flutter code this often isn't the best formatting, so trailing commas can be used to change the formatting a little that works better:
https://flutter.dev/docs/development/tools/formatting#using-trailing-commas
(source: flutter.dev)
After poking around for solutions to this for months, thinking it must have something to do with the line length, the word wrapping, or other things, and none of it worked, I realized that if one has "Enable SDK Formatter" checked, it will seemingly override all of that with dart_style's choices.
Kind of sad to turn it off, as I'm sure it must be doing some other things that are useful. But I just can't live with that odd formatting that obfuscates the actual structure of the code as soon as I hit Save. So, if you're doing it manually in the settings.json, I would do:
"dart.enableSdkFormatter": false,
Can i make a ExpansionPanel with header and body content from SQFLite database?
this is my code paste.ofcode.org/b8Mns5bSQxqyjX6BwD8DL8 I want to load the header and body from database
You are using ListView.builder to build the List. ListView.builder is meant for building UI widgets.
As it is not attached to the view (it's hanging in initState), ListView.builder will not have iterated once (you can put a print inside and see).
Solution is to use normal list
List.generate(data.length, (index) => new ItemKu(
false,
data[index]["category"],
new Container(
padding: new EdgeInsets.all(10.0),
child: new Text('Hello World'),
)
));
I have generated an image using the Flutter camera plugin.
I am trying to display it.
My path looks like:
/data/user/0/com.example.myapp/app_flutter/picture2.jpg
How should I load it ?
I tried :
new Image.network("file:///"+imagePath)
but I get the error :
Another exception was thrown: Invalid argument(s): No host specified in URI file:////data/user/0/com.example.myapp/app_flutter/picture2.jpg
The way is to use :
new Image.file(File(imagePath))
see stackoverflow questions
Use FileImage like below. It takes the File as the parameter.
_image = File(path);
Container(
padding: const EdgeInsets.all(1.0),
decoration: BoxDecoration(
color: Colors.white,
image: DecorationImage(
image: FileImage(_image), fit: BoxFit.cover)),
)