How to set a text background with Flutter?

TL;DR – (Updated 07-08-2019) Using style property (backgroundColor) Text( ‘Some text…’, style: TextStyle(backgroundColor: Colors.blue), ) Using style property (background) Text( ‘Some text…’, style: TextStyle(background: Paint()..color = Colors.blue), ) Using a DecoratedBox const DecoratedBox( decoration: const BoxDecoration(color: Colors.blue), child: const Text(‘Some text…’), ); Long answer First of all, welcome to Flutter and StackOverflow 🙂 That happens … Read more

Allow only two decimal number in flutter input?

Here you go! Hope it helps 🙂 import ‘package:flutter/material.dart’; import ‘package:flutter/services.dart’; import ‘dart:math’ as math; void main() { runApp(new MaterialApp(home: new MyApp())); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(“Flutter”), ), body: Form( child: ListView( … Read more

Bottom overflow by 30px

There are two solutions to this problem. Add resizeToAvoidBottomPadding: false to your Scaffold Scaffold( resizeToAvoidBottomPadding: false, body: …) Put your FilstList(searchtext: _text,) inside a scrollableView (like SingleChildScrollView or ListView)

How to change Status Bar and App Bar color in Flutter?

I tried the method SystemChrome.setSystemUIOverlayStyle(), as far as I tested (Flutter SDK v1.9.1+hotfix.2, running on iOS 12.1) it works perfect for Android. But for iOS, e.g. if your first screen FirstScreen() doesn’t have an AppBar, but the second SecondScreen() does, then at launch the method does set the color in FirstScreen(). However, after navigating back … Read more

Flutter : Custom Radio Button

Here is the full code class CustomRadio extends StatefulWidget { @override createState() { return new CustomRadioState(); } } class CustomRadioState extends State<CustomRadio> { List<RadioModel> sampleData = new List<RadioModel>(); @override void initState() { // TODO: implement initState super.initState(); sampleData.add(new RadioModel(false, ‘A’, ‘April 18’)); sampleData.add(new RadioModel(false, ‘B’, ‘April 17’)); sampleData.add(new RadioModel(false, ‘C’, ‘April 16’)); sampleData.add(new RadioModel(false, ‘D’, … Read more

Flutter – How to make a custom TabBar

You can use the TabBar widget to achieve this. I added a full example demonstrating how you can create this using the TabBar widget: CODE class StackOver extends StatefulWidget { @override _StackOverState createState() => _StackOverState(); } class _StackOverState extends State<StackOver> with SingleTickerProviderStateMixin { TabController _tabController; @override void initState() { _tabController = TabController(length: 2, vsync: this); … Read more

Preserving state between tab view pages

In case you want to keep the state of your screen in your TabBarView, you can use the mixin class called AutomaticKeepAliveClientMixin in your State class. After that you have to override the wantKeepAlive method and return true. It will looks like something that : class _SearchScreenState extends State<SearchScreen> with AutomaticKeepAliveClientMixin<SearchScreen>{ … @override Widget build(BuildContext … Read more

How to center column and row item in Flutter?

If you want the whole table to be Centered, use the mainAxisAlignment property of Column. Column mainAxisAlignment: MainAxisAlignment.center //Center Column contents vertically, crossAxisAlignment: CrossAxisAlignment.center //Center Column contents horizontally, Row mainAxisAlignment: MainAxisAlignment.center //Center Row contents horizontally, crossAxisAlignment: CrossAxisAlignment.center //Center Row contents vertically,