Flutter command not found

This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. Apparently, none of the Flutter commands are working in the terminal of Android Studio which I believe I am trying to run it at the root of my project. Output: bash: flutter: … Read more

Force Flutter navigator to reload state when popping

I have one StatefulWidget in Flutter with button, which navigates me to another StatefulWidget using Navigator.push(). On second widget I’m changing global state (some user preferences). When I get back from second widget to first, using Navigator.pop() the first widget is in old state, but I want to force it’s reload. Any idea how to … Read more

Check whether there is an Internet connection available on Flutter app

I have a network call to be executed. But before doing that I need to check whether the device have internet connectivity. This is what i have done so far: var connectivityResult = new Connectivity().checkConnectivity();// User defined class if (connectivityResult == ConnectivityResult.mobile || connectivityResult == ConnectivityResult.wifi) {*/ this.getData(); } else { neverSatisfied(); } Above method … Read more

How can I check if a Flutter application is running in debug?

I’m looking for a way to execute code in Flutter when the app is in Debug mode. Is that possible in Flutter? I can’t seem to find it anywhere in the documentation. Something like this If(app.inDebugMode) { print(“Print only in debug mode”); } How can I check if the Flutter application is running in debug … Read more

How to format DateTime in Flutter

I am trying to display the current DateTime in a Text widget after tapping on a button. The following works, but I’d like to change the format. Current approach DateTime now = DateTime.now(); currentTime = new DateTime(now.year, now.month, now.day, now.hour, now.minute); Text(‘$currentTime’), Result YYYY-MM-JJ HH-MM:00.000 Question How can I remove the :00.000 part? 15 Answers … Read more

setState() or markNeedsBuild called during build

class MyHome extends StatefulWidget { @override State<StatefulWidget> createState() => new MyHomePage2(); } class MyHomePage2 extends State<MyHome> { List items = new List(); buildlist(String s) { setState(() { print(“entered buildlist” + s); List refresh = new List(); if (s == ‘button0’) { refresh = [ new Refreshments(“Watermelon”, 250), new Refreshments(“Orange”, 275), new Refreshments(“Pine”, 300), new Refreshments(“Papaya”, … Read more