Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while executing code #50

Closed
johnfriend opened this issue Nov 6, 2020 · 4 comments · Fixed by #51
Closed

Error while executing code #50

johnfriend opened this issue Nov 6, 2020 · 4 comments · Fixed by #51

Comments

@johnfriend
Copy link

johnfriend commented Nov 6, 2020

Please find below the error message that I have received when I used the example file

Invalid argument(s): widget.routeName must be a String beginning with forward slash (/)

The relevant error-causing widget was:
LeviSplash file:///Users/*/Desktop/Flutter//lib/main.dart:7:13
When the exception was thrown, this was the stack:
#0 _SplashScreenState.initState (package:splashscreen/splashscreen.dart:86:7)
#1 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4765:58)
#2 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
#3 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
#4 Element.updateChild (package:flutter/src/widgets/framework.dart:3324:20)

What should i do ?


Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@Drifeter
Copy link

Drifeter commented Nov 6, 2020

I'm having the same problem, even with a new project:
#1 create a new flutter project
#2 update pubscec.yaml dependencies => splashscreen: ^1.3.3
#3 copy the example from the first page into main.dart:
`import 'package:flutter/material.dart';
import 'package:splashscreen/splashscreen.dart';

void main() {
runApp(new MaterialApp(
home: new MyApp(),
));
}

class MyApp extends StatefulWidget {
@OverRide
_MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State {
@OverRide
Widget build(BuildContext context) {
return new SplashScreen(
seconds: 14,
navigateAfterSeconds: new AfterSplash(),
title: new Text(
'Welcome In SplashScreen',
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
),
image: new Image.network('https://i.imgur.com/TyCSG9A.png'),
backgroundColor: Colors.white,
styleTextUnderTheLoader: new TextStyle(),
photoSize: 100.0,
onClick: () => print("Flutter Egypt"),
loaderColor: Colors.red);
}
}

class AfterSplash extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Welcome In SplashScreen Package"),
automaticallyImplyLeading: false),
body: new Center(
child: new Text(
"Done!",
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 30.0),
),
),
);
}
}
`
#4 Run Flutter and get the error:

════════ Exception caught by widgets library ═══════════════════════════════════
The following ArgumentError was thrown building MyApp(state: _MyAppState#1b99e):
Invalid argument(s): widget.routeName must be a String beginning with forward slash (/)

The relevant error-causing widget was
MyApp
lib\main.dart:6
When the exception was thrown, this was the stack
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 216:49 throw
packages/splashscreen/splashscreen.dart 87:80 initState
packages/flutter/src/widgets/framework.dart 4812:57 [_firstBuild]
packages/flutter/src/widgets/framework.dart 4649:5 mount
packages/flutter/src/widgets/framework.dart 3615:13 inflateWidget
...
════════════════════════════════════════════════════════════════════════════════

@KarimMohamed20
Copy link
Member

Thanks for this report, I will check it and push a new version soon.

@hons82
Copy link

hons82 commented Nov 6, 2020

The if statement at line 83 should probably look something like this

if (widget.routeName != null && widget.routeName is String && "${widget.routeName[0]}" != "/") throw new ArgumentError("widget.routeName must be a String beginning with forward slash (/)");

@Drifeter
Copy link

Drifeter commented Nov 6, 2020

The if statement at line 83 should probably look something like this

if (widget.routeName != null && widget.routeName is String && "${widget.routeName[0]}" != "/") throw new ArgumentError("widget.routeName must be a String beginning with forward slash (/)");

Thanks, for me solved the issue 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants