Skip to content

failed to generate random colors #12

@EluvK

Description

@EluvK

Encountering this issue after upgrading to the latest version 1.0.17

════════ Exception caught by widgets library ═══════════════════════════════════  
The following StateError was thrown building MyApp(dirty):  
Bad state: No element  

When the exception was thrown, this was the stack:  
#0      Iterable.first (dart:core/iterable.dart:644:7)  
iterable.dart:644  
#1      RandomColor._getColorInfo (package:flutter_randomcolor/src/randomcolor.dart:378:10)  
randomcolor.dart:378  
#2      RandomColor._pickSaturation (package:flutter_randomcolor/src/randomcolor.dart:234:29)  
randomcolor.dart:234  
#3      RandomColor._pick (package:flutter_randomcolor/src/randomcolor.dart:146:9)  
randomcolor.dart:146  
#4      RandomColor.getColor (package:flutter_randomcolor/src/randomcolor.dart:40:35)  
randomcolor.dart:40  
#5      RandomColor.getColorObject (package:flutter_randomcolor/src/randomcolor.dart:55:23)  

Minimal code to reproduce:

import 'package:flutter/material.dart';  
import 'package:flutter_randomcolor/flutter_randomcolor.dart';  

void main() {  
  runApp(const MyApp());  
}  

class MyApp extends StatelessWidget {  
  const MyApp({super.key});  

  @override  
  Widget build(BuildContext context) {  
    return MaterialApp(  
      title: 'Flutter Demo',  
      home: Container(  
        color: RandomColor.getColorObject(Options(luminosity: Luminosity.dark)),  
        child: const Text('Hello World'),  
      ),  
    );  
  }  
}  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions