ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your flutter PATH. In Flutter

You have to set the JAVA_HOME Environment Variable. On Windows, I solved the issue as follows: Download the Java JDK from here and install it. (This links to version 15, which requires you to create an account in order to download. Version 16 is available to download without creating an account, but it has caused …

Read more

Flutter: Changing the current tab in tab bar view using a button

You need to get the TabBar controller and call its animateTo() method from the button onPressed() handle. import ‘package:flutter/material.dart’; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: ‘Flutter Demo’, home: new MyTabbedPage(), ); } } class MyTabbedPage extends StatefulWidget { const MyTabbedPage({Key key}) : …

Read more

How to add shadow to the text in flutter?

Text shadows are now a property of TextStyle as of this commit To enable text shadows, please make sure you are on an up-to-date version of Flutter ($ flutter upgrade) and provide a List<Shadow> to TextStyle.shadows: import ‘dart:ui’; … Text( ‘Hello, world!’, style: TextStyle( shadows: <Shadow>[ Shadow( offset: Offset(10.0, 10.0), blurRadius: 3.0, color: Color.fromARGB(255, 0, …

Read more

Flutter – DropdownButton overflow

The easiest solution is to add the isExpanded property to true in DropdownButton For example: new DropdownButton( isExpanded: true, //Adding this property, does the magic items: [ new DropdownMenuItem( child: Text(“Some large text that needs to be wrapped or ellipsized”, overflow: TextOverflow.ellipsis), ), new DropdownMenuItem( child: Text(“This is another large text that needs to be …

Read more

Flutter: Get passed arguments from Navigator in Widget’s state’s initState

use MaterialApp.onGenerateRoute property like this: onGenerateRoute: (RouteSettings settings) { print(‘build route for ${settings.name}’); var routes = <String, WidgetBuilder>{ “hello”: (ctx) => Hello(settings.arguments), “other”: (ctx) => SomeWidget(), }; WidgetBuilder builder = routes[settings.name]; return MaterialPageRoute(builder: (ctx) => builder(ctx)); }, now you can simply use NavigatorState.pushNamed: Navigator.of(context).pushNamed(“hello”, arguments: “world”); here you have some test Hello widget: class Hello …

Read more