Splashscreem on Flutter - Error with Bottom Bar

Asked

Viewed 28 times

1

Hey, how you doing? So, I can’t make the splash screen work on the main where Curved Bottom is, because both of them, so the following doc is added to the home: of main.dart. When I add the splash button it stops working and so on for both. How could I make the splash work even with Curved Bottom on my main?

That’s my main code along with the button I added the two codes in main, but I can’t call them

 import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:splashscreen/splashscreen.dart';
import 'Anonymos.dart';
import 'Homepage.dart';

void main() => runApp(MaterialApp(home: BottomNavBar()));

class BottomNavBar extends StatefulWidget {

  BottomNavBar({Key key,})
      : super(key: key);
  @override
  _BottomNavBarState createState() => _BottomNavBarState();
}

class _BottomNavBarState extends State<BottomNavBar> {
  int _pageIndex = 0;
  GlobalKey _bottomNavigationKey = GlobalKey();

  List pages = [
    MyRoute(
      iconData: Icons.announcement,
      page: Homepage(),
    ),
    MyRoute(
      iconData: Icons.email,
      page: MensagemChat(),
    ),
    MyRoute(
      iconData: Icons.account_circle_outlined,
      page: MensagemChatAnonimo(),
    )
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: CurvedNavigationBar(
        key: _bottomNavigationKey,
        index: 0,
        height: 50.0,
        items: pages
            .map((p) => Icon(
          p.iconData,
          size: 30,
        ))
            .toList(),
        color: Colors.indigo[50],
        buttonBackgroundColor: Colors.white,
        backgroundColor: Colors.blueAccent,
        animationCurve: Curves.easeInOut,
        animationDuration: Duration(milliseconds: 600),
        onTap: (index) {
          setState(() {
            _pageIndex = index;
          });
        },
      ),
      backgroundColor: Colors.blueAccent,
      body: pages[_pageIndex].page,
    );
  }
}

class MyRoute {
  final IconData iconData;
  final Widget page;

  MyRoute({this.iconData, this.page});
}

class splashScreen extends StatefulWidget {

  splashScreen({Key key, this.title}) : super(key: key);

  final String title;


  @override
  _splashScreenState createState() => _splashScreenState();
}

class _splashScreenState extends State<splashScreen> {
  @override
  Widget build(BuildContext context) {
    return _introScreen();
  }
}

Widget _introScreen() {
  return Stack(
    children: <Widget>[
      SplashScreen(
        seconds: 5,
        gradientBackground: LinearGradient(
          begin: Alignment.topRight,
          end: Alignment.topCenter,
          colors: [
            Color(0xff2474fd),
            Color(0xff2882f1)
          ],
        ),
        navigateAfterSeconds: Homepage(),
        loadingText: Text('Carregando',
          style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600,),),
        loaderColor: Colors.redAccent,
        styleTextUnderTheLoader: const TextStyle(
            decorationStyle: TextDecorationStyle.wavy),
      ),
      Container(
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage("Assets/image/Splas.png"),
            fit: BoxFit.contain,
          ),
        ),
      ),

    ],
  );
}
  • 2

    It’s hard to imagine what behavior is going on and what you think is wrong, and what behavior is right. Don’t have images that illustrate? Your code is not a viable and executable example, you can’t copy it and try to reproduce what you are doing. A splash screen is a screen that appears as soon as we enter the app in order to upload information to its operation, you must use some state management strategy in the app to make this control.

  • I understand, and thank you for taking the little time to help me! I did what you indicated and simply created another.Dart file to which I migrated the Bottom bar. And it’s working fine, thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.