Flutter how to change color depending status from JSON API

Flutter how to change color depending status from JSON API

Content Index :

Flutter how to change color depending status from JSON API
Tag : json , By : alexmajy
Date : November 29 2020, 12:01 PM

I wish this helpful for you You can create a method to return the Color according the condition (assuming event.toString() = Rejected , Approved or Submitted):

Color _getColorByEvent(String event) {
  if (event == "Approved") return Colors.green;
  if (event == "Rejected") return Colors.red;
  return Colors.blue;


                color: _getColorByEvent(event.toString()), // i want to change the color
                border: Border.all(width: 0.8),
                borderRadius: BorderRadius.circular(12.0),

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to change status and navigation bar color in Flutter?

Tag : flutter , By : nhuser
Date : March 29 2020, 07:55 AM
like below fixes the issue 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 to FirstScreen() from SecondScreen(), the status bar color becomes transparent.
I come up with a hacky workaround by setting an AppBar() with zero height, then status bar's color gets changed by the AppBar, but the AppBar itself is not visible. Hope it would be useful to someone.
// FirstScreen that doesn't need an AppBar
Widget build(BuildContext context) {
  return Scaffold(
    appBar: PreferredSize(
        preferredSize: Size.fromHeight(0),
        child: AppBar( // Here we create one to set status bar color
          backgroundColor: Colors.black, // Set any color of status bar you want; or it defaults to your theme's primary color

// SecondScreen that does have an AppBar
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar()

How to change status bar color in Flutter?

Tag : dart , By : Santhanam
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I am trying to change the status bar color to white. I found this pub on flutter. I tried to use the example code on my dart files. , Works totally fine in my app
import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: app_title,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      home: HomePage(title: home_title),
  statusBarColor: Colors.white

Status bar color doesn't change in flutter

Tag : flutter , By : Mariocki
Date : March 29 2020, 07:55 AM
should help you out To set status bar color you should write code in 'build' method, as below example -
      Widget build(BuildContext context) {
            statusBarColor: Color.fromRGBO(41, 167, 77, 50),
            //or set color with: Color(0xFF0000FF)
            statusBarIconBrightness: Brightness.dark));
    return Scaffold();

How to change the Status Bar color in Flutter when we are using an AppBar?

Tag : flutter , By : Sergio Rudenko
Date : January 06 2021, 03:27 AM
I hope this helps .
I want to define a specific color myself and not let the AppBar do it automatically?
  statusBarColor: Colors.yellow.shade600,
  statusBarBrightness: Brightness.light,
  statusBarIconBrightness: Brightness.dark,

Flutter: Change status bar color in iOS

Tag : flutter , By : Lee KW
Date : March 29 2020, 07:55 AM
it fixes the issue I want to change status bar color with package:flutter/services.dart package but it doesn't work. I am using Mac and iOS simulator: , Edit:
appBar: AppBar(
  elevation: 0,
  brightness: Brightness.light, // this makes status bar text color black
  backgroundColor: Colors.white,
AppBar(backgroundColor: Colors.red) // this changes both AppBar and status bar color in iOS
Related Posts Related QUESTIONS :
  • JSON parsing problem in BlackBerry
  • GWT: How can I use JsonpRequestBuilder to handle a Json response of a list
  • JSON feed to Java Object
  • json character encoding problem
  • JSON Loading Speed Optimization: Use online API vs. create my own API based on that?
  • How can I access some JSON documents from my AWS lambda function?
  • How to extract multiple correlating variables from a JSon
  • Schema/Resolve for nested objects graphql/mongoose
  • Dynamics 365 opportunity EntityType processid and stagename error
  • How to convert dataframe output to json format and then Normalize the data?
  • In Angular, how do I avoid a "Property 'json' does not exist on type 'Object'" error?
  • Python giving vague error when trying to parse JSON object
  • Invalid JSON literal: xxx when calling ASMX service from Angular8
  • How to write the data converted from json to csv without skipping the rows
  • Unpacking JSON Into Flat Format
  • TypeError: items is undefined while reading a json using fetch in reactjs
  • How to insert date to the web path api
  • schema validation get value from sum of another value of json
  • Deleting a field in nested objects in JQ
  • Get multiple JSON keypair values within a JSON object only if a specific keypair value matches iterable
  • parse contents from returned json to el-dropdown-item
  • Replace content by key in JSON
  • JSON parsing using String Condition with JMESPATH
  • Only Output Rule Alerts to Suricata EVE
  • How to unmarshal a json string with a hyphen in key to a struct?
  • How can I aggregate sub-values into arrays with jq?
  • How to parse JSON array in Flutter with length of one?
  • Python: Combine multiple lists into one JSON array
  • jq - parsing complex JSON into a string
  • Json array elements duplication using jolt
  • How to read multiple json files
  • How to configure different levels for different appenders but under same logger in logback
  • How to skip text at the beginning of a json file in python
  • Value of type 'Type' has no subscripts Error Swift
  • Map mongo aggregation result to array
  • How to convert Matrix HTML to JSON in Typescript (for sending through api)
  • jsonschema - oneOf keyword behaves unexpectedly
  • Match password efficiently in Spring Boot - JPA
  • Import ndjson into elasticsearch 7.2 by command line
  • Extract inner field value from JSON document based on a key using jq
  • How can I decode a nested array of multiple types?
  • How to stop JSON Path returning object
  • How do I Parse from Multiple JSON files in Roku Scenegraph (brightscript)?
  • anyOf in OAS 3.0 for requestBody that is url encoded form data does not render obvious inputs in swagger UI
  • make requestBody fields optional in swaggerUI
  • Linkedin API: How to activate r_basicprofile as a permission?
  • Writing a given sequence of int's as an array of hex values in Jackson
  • find and delete nested json object in Go
  • Using Postman to test API, where is the Postman call?
  • Since Spark 2.3, the queries from raw JSON/CSV files are disallowed when the referenced columns only include the interna
  • Cannot match integer value using regex - error (at <stdin>:6): number not a string or array
  • Get key names from the JSON
  • Combining multiple JSONs with id
  • Creating a model for a json
  • AJAX success function not being called even though HTTP 200 is returned
  • Json schema for recursive structure not working
  • How can I insert following JSON in MongoDB collection as different documents
  • How to create VSCode task creating a file without BOM
  • How can I wrap an existing JSON file's contents as part of an object?
  • How to merge two different JSON (using python)
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com