How to apply flex in flutter

Expanded is Similar to Flex and supports adding flex, You can wrap your children with Expanded and give flex as below Updated Code : Container( child: new Row( children: <Widget>[ new Expanded ( flex:1, child : Column( children: <Widget>[new Text(“Hello World”)], ),), new Expanded( flex :2, child: Column( children: <Widget>[ new Text( “This is a … Read more

How to change speed of a hero animation in flutter

To modify the transition speed, you’ll have to adjust the PageRoute transition duration (as already pointed out by @diegoveloper). If you wanna keep the default transition, you can create a class implementing MaterialPageRoute. If you already have your own transition or want to create one you can use the PageRouteBuilder to easily build your own. … Read more

Is it possible to underline text with some height between text and underline line?

Here’s a simple hacky way to do it: Text( “Forgot Password?”, style: TextStyle( shadows: [ Shadow( color: Colors.red, offset: Offset(0, -5)) ], color: Colors.transparent, decoration: TextDecoration.underline, decorationColor: Colors.blue, decorationThickness: 4, decorationStyle: TextDecorationStyle.dashed, ), ) I wrote an article about text underlining with a few other solutions but this is my favorite.

How to achieve rounded corners on new OutlinedButton widget in Flutter?

You can use OutlinedButton.styleFrom property: OutlinedButton( style: OutlinedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), ), side: BorderSide(width: 2, color: Colors.green), ), onPressed: () {}, child: Text(‘Button’), ) From the source code /// All parameters default to null, by default this method returns /// a [ButtonStyle] that doesn’t override anything. /// /// For example, to override the default … Read more

How to use data from Provider during initState in Flutter application

You need to use the context to call Provider.of() so you can add addPostFrameCallback() which is called after the first build, there you can use the context @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { auth = Provider.of<Auth>(context, listen: false); }); }

Get the Global Context in Flutter

If above solution does not works please try this solution. Create the class. Here it named as NavigationService import ‘package:flutter/material.dart’; class NavigationService { static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(); } Set the navigatorKey property of MaterialApp in the main.dart Widget build(BuildContext context) { return MaterialApp( navigatorKey: NavigationService.navigatorKey, // set property ) } Great! Now you can … Read more

Programmatically Lighten or Darken a hex color in dart

For people who want to darken or lighten Color instead of hex string // ranges from 0.0 to 1.0 Color darken(Color color, [double amount = .1]) { assert(amount >= 0 && amount <= 1); final hsl = HSLColor.fromColor(color); final hslDark = hsl.withLightness((hsl.lightness – amount).clamp(0.0, 1.0)); return hslDark.toColor(); } Color lighten(Color color, [double amount = .1]) … Read more