AppCheap / awesome_bottom_bar

BSD 3-Clause "New" or "Revised" License
46 stars 34 forks source link

Error: A constant constructor can't call a non-constant super constructor. #10

Closed ompadmani71 closed 1 year ago

ompadmani71 commented 1 year ago

import 'package:flutter/material.dart'; import 'package:awesome_bottom_bar/awesome_bottom_bar.dart';

class Salomon extends StatefulWidget { static const String routeName = '/product'; final List items;

const Salomon({ Key? key, required this.items, }) : super(key: key);

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

class _SalomonState extends State { int visit = 0;

@override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ const SizedBox(height: 87), Container(), BottomBarSalomon( items: widget.items, color: Colors.blue, backgroundColor: Colors.white, colorSelected: Colors.white, backgroundSelected: Colors.blue, indexSelected: visit, animated: false, onTap: (index) => setState(() { visit = index; }), ), ], ), bottomNavigationBar: BottomBarSalomon( items: widget.items, color: Colors.blue, backgroundColor: Colors.red.withOpacity(0.4), colorSelected: Colors.white, backgroundSelected: Colors.blue, indexSelected: visit, onTap: (index) => setState(() { visit = index; }), ), ); } }

========================================================== image

image

And if I remove the const from 'C:\Users\LENOVO\AppData\Local\Pub\Cache\hosted\pub.dev\awesome_bottom_bar-1.2.3\lib\widgets\inspired\stack.dart' then it's give me another error

which is here image

please give me a soluction for the same asap.

Rimansh1464 commented 1 year ago

@ompadmani71 please add key in TabItem Ex: List items = [ TabItem( key: 'home', // Assign a unique key icon: Icons.home, title: 'Home', ), TabItem( key: 'tools', // Assign a unique key icon: Icons.add_chart_outlined, title: 'Tools', ), TabItem( key: 'activity', // Assign a unique key icon: Icons.add_business_sharp, title: 'Activity', ), ];

ompadmani71 commented 1 year ago

Thank you @Rimansh1464

prince-appiah commented 1 year ago

@Rimansh1464 I provided the key in my tab items but still got the error. Any other solution I could use?