1

when I use the following code snippet in flutter

import 'package:flutter/material.dart';
import 'package:flutter_app/features/note/presentation/screens/note_list.dart';
import 'package:flutter_app/features/note/presentation/screens/create_note.dart';

class Routes {
   static Map<String, WidgetBuilder> getRoutes() {
    return {
      '/': (context) => const NoteList(),
      '/create': (context) => const CreateNote(),
    };
  }
}

I get this issue enter image description here

but when I remove absolute path from the code snippet issue gets resolved


import 'package:flutter/material.dart';
import '../features/note/presentation/screens/note_list.dart';
import '../features/note/presentation/screens/create_note.dart';

class Routes {
   static Map<String, WidgetBuilder> getRoutes() {
    return {
      '/': (context) => const NoteList(),
      '/create': (context) => const CreateNote(),
    };
  }
}

I tried to use relative path and and fixed the issue.

3
  • you should provide code where CounterBloc is created Commented Oct 2, 2024 at 11:38
  • Hello @VladyslavUlianytskyi, what did you mean? Commented Oct 6, 2024 at 0:03
  • on the error screen there is CounterBloc. how do you create tthe instance of CounterBloc and where? - that what I mean Commented Oct 6, 2024 at 7:15

1 Answer 1

1

In your main App class make this:


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

  @override
  Widget build(BuildContext context) {
    return MultiBlocProvider(
      providers: [
        BlocProvider(
          create: (_) => CounterBloc(),
        ),
        BlocProvider(
          create: (_) => AnotherBloc(),
        ),
....
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.