Flutter defining global color resources
Create a file app_colors.dart with the following, add more colors as needed. Color is defined with hex strings. The first FF is the alpha value, the next 2 is for Red, the next 2 is for Green and the last 2 is for Blue
import 'dart:ui';
class AppColors {
static const primaryColor = Color(0xFFF0E015);
static const secondaryColor = Color(0xFFAEF015);
static const accentColor = Color(0xFF15F0BD);
}
Use the color anywhere in the app like this.
import 'package:flutter/material.dart';
import 'app_colors.dart';
class LoadingIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: CircularProgressIndicator(
valueColor: new AlwaysStoppedAnimation(AppColors.primaryColor),
),
),
backgroundColor: Colors.secondaryColor,
);
}
}
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts