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: 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

Flutter: There should be exactly one item with [DropdownButton]’s value

Well, since no problem has an exact same solution. I was facing the same issue with my code. Here is How I fixed this. CODE of my DropdownButton: DropdownButton( items: _salutations .map((String item) => DropdownMenuItem<String>(child: Text(item), value: item)) .toList(), onChanged: (String value) { setState(() { print(“previous ${this._salutation}”); print(“selected $value”); this._salutation = value; }); }, value: …

Read more

wrapping Scaffold with Container for gradient background, How to set gradient to container background in flutter?

You can also add a gradient to the AppBar like this, new Scaffold( appBar: AppBar( title: Center(child: Text(‘Awesome AppBar’)), flexibleSpace: Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [ const Color(0xFF3366FF), const Color(0xFF00CCFF), ], begin: const FractionalOffset(0.0, 0.0), end: const FractionalOffset(1.0, 0.0), stops: [0.0, 1.0], tileMode: TileMode.clamp), ), ), child: …, ), body: …, ); LinearGradient parameters: …

Read more

How can I change the background color of Elevated Button in Flutter from function?

You can style ElevatedButton by using the styleFrom static method or the ButtonStyle class. The first one is more convenient than the second one. Using styleFrom to style an ElevatedButton: ElevatedButton( child: Text(‘Button’), onPressed: () {}, style: ElevatedButton.styleFrom({ Color primary, // set the background color Color onPrimary, Color onSurface, Color shadowColor, double elevation, TextStyle textStyle, …

Read more