Stacked-Org / stacked

A Flutter application architecture created from real world scenarios
MIT License
935 stars 256 forks source link

[bug]: Error: No named parameter with the name 'vsync'. #918

Closed Al-Krause-ex closed 1 year ago

Al-Krause-ex commented 1 year ago

Describe the bug

Errors:

_pub.dev/stacked-3.2.0/lib/src/view_models/ui/skeletonloader.dart:106:19: Error: No named parameter with the name 'vsync'. vsync: this, ^^^^^ _lib/src/widgets/animatedsize.dart:28:9: Context: Found this candidate, but the arguments don't match. const AnimatedSize({ ^^^^^^^^^^^^

My code:

lib/core/app/routes.dart

import 'package:todos_frontend/presentation/show_todos/show_todos_view.dart';

@StackedApp(routes: [
 AdaptiveRoute(page: ShowTodosView, initial: true),
])
class App {}

routes.router.dart


// **************************************************************************
// StackedNavigatorGenerator
// **************************************************************************

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart' as _i1;
import 'package:stacked_services/stacked_services.dart' as _i3;
import 'package:todos_frontend/presentation/show_todos/show_todos_view.dart'
    as _i2;

class Routes {
  static const showTodosView = '/';

  static const all = <String>{showTodosView};
}

class StackedRouter extends _i1.RouterBase {
  final _routes = <_i1.RouteDef>[
    _i1.RouteDef(
      Routes.showTodosView,
      page: _i2.ShowTodosView,
    )
  ];

  final _pagesMap = <Type, _i1.StackedRouteFactory>{
    _i2.ShowTodosView: (data) {
      return _i1.buildAdaptivePageRoute<dynamic>(
        builder: (context) => const _i2.ShowTodosView(),
        settings: data,
      );
    }
  };

  @override
  List<_i1.RouteDef> get routes => _routes;
  @override
  Map<Type, _i1.StackedRouteFactory> get pagesMap => _pagesMap;
}

extension NavigatorStateExtension on _i3.NavigationService {
  Future<dynamic> navigateToShowTodosView([
    int? routerId,
    bool preventDuplicates = true,
    Map<String, String>? parameters,
    Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
        transition,
  ]) async {
    return navigateTo<dynamic>(Routes.showTodosView,
        id: routerId,
        preventDuplicates: preventDuplicates,
        parameters: parameters,
        transition: transition);
  }

  Future<dynamic> replaceWithShowTodosView([
    int? routerId,
    bool preventDuplicates = true,
    Map<String, String>? parameters,
    Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
        transition,
  ]) async {
    return replaceWith<dynamic>(Routes.showTodosView,
        id: routerId,
        preventDuplicates: preventDuplicates,
        parameters: parameters,
        transition: transition);
  }
}

main.dart

import 'package:stacked_services/stacked_services.dart';

import 'core/app/routes.router.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Fullstack Todo App',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      navigatorKey: StackedService.navigatorKey,
      onGenerateRoute: StackedRouter().onGenerateRoute,
    );
  }
}

Version

Flutter version 3.9.0-0.2.pre Dart version 3.0.0 (build 3.0.0-290.3.beta)

To reproduce

  1. Create routes.dart
  2. run build_runner
  3. add in main.dart (navigatorKey: StackedService.navigatorKey, onGenerateRoute: StackedRouter().onGenerateRoute,)
  4. run
FilledStacks commented 1 year ago

Hi, thanks for opening a well structured issue. Next time when you add code please use


```dart
Your code here will be formatted as code. Don't add ` around every line. And end with "```" as well. 

In terms of the bud I'll check this out. What version of the stacked_cli are you using to generate the app?

Al-Krause-ex commented 1 year ago

Hi, thanks for opening a well structured issue. Next time when you add code please use


```dart
Your code here will be formatted as code. Don't add ` around every line. And end with "```" as well. 

In terms of the bud I'll check this out. What version of the stacked_cli are you using to generate the app?

Thanks for the advice!

My pubspec.yaml

environment:
  sdk: '>=3.0.0-290.3.beta <4.0.0'

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  dio: ^5.0.3
  either_dart: ^0.3.0
  flutter_hooks: ^0.18.6
  get_it: ^7.2.0
  injectable: ^2.1.1
  stacked: ^3.2.0
  stacked_services: ^1.0.0
  retrofit: ^4.0.1

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.0
  build_runner: ^2.4.1
  very_good_analysis: ^4.0.0+1
  stacked_generator: ^1.0.0
  injectable_generator: ^2.1.5
  retrofit_generator: ^6.0.0+1
Al-Krause-ex commented 1 year ago

Now I tried to create an application through stacked_cli, having previously installed it (stacked_cli: ^1.5.1)

Ran the command: stacked create app my_app

I tried to run the project through the emulator / physical. device, same problem

main.dart

import 'package:flutter/material.dart';
import 'package:my_app/app/app.bottomsheets.dart';
import 'package:my_app/app/app.dialogs.dart';
import 'package:my_app/app/app.locator.dart';
import 'package:my_app/app/app.router.dart';
import 'package:my_app/ui/common/app_colors.dart';
import 'package:stacked_services/stacked_services.dart';

void main() {
  setupLocator();
  setupDialogUi();
  setupBottomSheetUi();

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: Theme.of(context).copyWith(
        primaryColor: kcBackgroundColor,
        focusColor: kcPrimaryColor,
        textTheme: Theme.of(context).textTheme.apply(
              bodyColor: Colors.black,
            ),
      ),
      initialRoute: Routes.startupView,
      onGenerateRoute: StackedRouter().onGenerateRoute,
      navigatorKey: StackedService.navigatorKey,
      navigatorObservers: [
        StackedService.routeObserver,
      ],
    );
  }
}

lib/app/app.dart

import 'package:my_app/ui/bottom_sheets/notice/notice_sheet.dart';
import 'package:my_app/ui/dialogs/info_alert/info_alert_dialog.dart';
import 'package:my_app/ui/views/home/home_view.dart';
import 'package:my_app/ui/views/startup/startup_view.dart';
import 'package:stacked/stacked_annotations.dart';
import 'package:stacked_services/stacked_services.dart';
// @stacked-import

@StackedApp(
  routes: [
    MaterialRoute(page: HomeView),
    MaterialRoute(page: StartupView),
    // @stacked-route
  ],
  dependencies: [
    LazySingleton(classType: BottomSheetService),
    LazySingleton(classType: DialogService),
    LazySingleton(classType: NavigationService),
    // @stacked-service
  ],
  bottomsheets: [
    StackedBottomsheet(classType: NoticeSheet),
    // @stacked-bottom-sheet
  ],
  dialogs: [
    StackedDialog(classType: InfoAlertDialog),
    // @stacked-dialog
  ],
)
class App {}

pubspec.yaml

name: my_app
description: An app build with the stacked framework
publish_to: 'none'

version: 1.0.0+1

environment:
  sdk: ">=2.17.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2

  stacked: ^3.2.0
  stacked_services: ^1.0.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^1.0.0
  build_runner: ^2.2.0

  stacked_generator: ^1.0.0
  mockito: ^5.3.2

flutter:
  uses-material-design: true
FilledStacks commented 1 year ago

@Al-Krause-ex I'm testing to see if I can reproduce now.

Edit:

Could you please upload a repo that reproduces the issue so I can check it out.

It might be an environment issue. We're don't supporting version later than stable.

kartalbas commented 1 year ago

just today upgraded to version 3.10.0 on STABLE channel and got same issue

flutter doctor -v [√] Flutter (Channel stable, 3.10.0, on Microsoft Windows [Version 10.0.22621.1702], locale de-CH) • Flutter version 3.10.0 on channel stable at d:\bin\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 84a1e904f4 (28 hours ago), 2023-05-09 07:41:44 -0700 • Engine revision d44b5a94c9 • Dart version 3.0.0 • DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2) • Android SDK at D:\bin\android\sdk • Platform android-33, build-tools 33.0.2 • Java binary at: C:\Program Files\Java\jdk-18.0.2.1\bin\java • Java version Java(TM) SE Runtime Environment (build 18.0.2.1+1-1) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop for Windows (Visual Studio Enterprise 2022 17.5.5) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Enterprise • Visual Studio Enterprise 2022 version 17.5.33627.172 ! Unable to locate a Windows 10 SDK. If building fails, install the Windows 10 SDK in Visual Studio.

[!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] VS Code (version 1.78.1) • VS Code at C:\Users\mkadm\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.52.0

[√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.1702] • Chrome (web) • chrome • web-javascript • Google Chrome 113.0.5672.93 • Edge (web) • edge • web-javascript • Microsoft Edge 113.0.1774.35

[√] Network resources • All expected network resources are available.

! Doctor found issues in 2 categories.

DanilKarasev commented 1 year ago

Same thing here, flutter version is 3.10.0

Error (Xcode): ../../.pub-cache/hosted/pub.dev/stacked-3.2.3/lib/src/view_models/ui/skeleton_loader.dart:105:19: Error: No named parameter with the name 'vsync'.

FilledStacks commented 1 year ago

I'll check this out. It might be a Flutter version 3.10 issue.

I'm busy wrapping up the Stacked Flutter Web course. It's been taking up most of my time. I will be releasing it tomorrow. After then I'll have some time to look at this issue.

I'll try get my focus on it tomorrow before the course releases.

FilledStacks commented 1 year ago

@ferrarafer can you take a look at this on the latest Flutter version. Lets see if there's an issue that we can fix up.

FilledStacks commented 1 year ago

Please check if this is still happening on stacked 3.2.5

thorito commented 1 year ago

Please check if this is still happening on stacked 3.2.5

Fixed with the latest update.

Thank you