Flutter/Dart: Convert HEX color string to Color?

前端 未结 5 837
醉酒成梦
醉酒成梦 2020-12-10 02:24

Our database has colors saved as a String like \"#AABBCC\" and so I\'m basically looking for a function like this: Color.parseColor(\"#AABBCC\"); f

5条回答
  •  再見小時候
    2020-12-10 03:05

    1- Install Hexcolor plugin

    dependencies:
      flutter:
        sdk: flutter
      hexcolor: ^1.0.4
    

    2- Import the plugin in your class

    import 'package:hexcolor/hexcolor.dart';
    

    Now Use the plugin like this,

    Container(
              color: Hexcolor("#0EBB64"),
              child: Center(child: Image.asset("images/marker.png",width: 100,height: 100,),),
            )
    

提交回复
热议问题