DPLYR-dev / SplashScreenFlutterPackage

A small splashscreen used as intro for flutter applications easily with a lot of customizations ❤️🥳
MIT License
294 stars 123 forks source link

Error while executing code #50

Closed johnfriend closed 3 years ago

johnfriend commented 3 years ago

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):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

Drifeter commented 3 years ago

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/ddcruntime/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 commented 3 years ago

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

hons82 commented 3 years ago

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 commented 3 years ago

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 👍