Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: Colors defined in multiple packages

How would you circumvent this problem?

The name 'Colors' is defined in the libraries 'colors.dart' and 'v3.dart'.

Conflicting packages:

  • import 'package:flutter/material.dart';
  • import 'package:googleapis/calendar/v3.dart';

Print Screen to MSPaint to Snipping Tool xd

like image 487
SeaRoth Avatar asked Nov 29 '22 13:11

SeaRoth


1 Answers

import 'package:googleapis/calendar/v3.dart' as v3;

...

backgroundColor: v3.Colors.teal

If you don't need Colors from one of these two packages anyway, you can also use

import 'package:flutter/material.dart' hide Colors;

or explicitly show what you need from one library (hides all not explicitly shown)

import 'package:flutter/material.dart' show StatefulWidget, StatelessWidget;
like image 194
Günter Zöchbauer Avatar answered Dec 05 '22 18:12

Günter Zöchbauer