'Router' is imported from both 'package:fluro/src/router.dart' and 'package:flutter/src/widgets/router.dart'

Viewed 3214

I was using Fluro package for navigating. Fluro and Flutter are using 'Router'. So their classes merged. How could I fix this?

lib/routers/routers.dart:2:1: Error: 'Router' is imported from both 'package:fluro/src/router.dart' and 'package:flutter/src/widgets/router.dart'. import 'package:flutter/material.dart'

I faced with that error when upgraded Flutter to 1.20.0.

2 Answers

Change

import 'package:flutter/material.dart'

with

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

in your navigating class that using fluro. So you could use fluro's Router now.

You can alias the Fluro library with the as keyword:

import 'package:flutter/material.dart'
import 'package:fluro/src/router.dart' as Fluro // Alias to avoid conflicts

Then use the alias for any class, method or symbol in the imported library:

var x = Fluro.Router(...)
Related