Панель вкладок флаттера NoSuchMethodError: NoSuchMethodError - PullRequest
0 голосов
/ 08 января 2019

Я создаю приложение, используя флаттер с TabBar, который используется для фильтрации списка по категориям. Однако, когда TabBar инициируется, он выдает следующую ошибку:

flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following NoSuchMethodError was thrown building _TabStyle(animation: kAlwaysDismissedAnimation,
flutter: dirty, state: _AnimatedState#71498):
flutter: The method 'withAlpha' was called on null.
flutter: Receiver: null
flutter: Tried calling: withAlpha(178).....

Код изначально работал нормально. Но симулятор теперь больше не отображает тапбар. Вместо этого симулятор имеет ошибку, утверждающую, что дно переполнено на 99870 пикселей

class LocationListWidget extends StatefulWidget {
  final List<Location> listOfLocations;
  @override
  State<StatefulWidget> createState() => new LocationListView();
  LocationListWidget(this.listOfLocations);
}

class LocationListView extends State<LocationListWidget>
with SingleTickerProviderStateMixin {

TabController _controller;

  static const List<TopButtons> typeList = const <TopButtons>[
const TopButtons(title: "Places", icon: Icons.directions_walk),
const TopButtons(title: "Shop", icon: Icons.shop),
const TopButtons(title: "Vineyards", icon: Icons.local_drink),
const TopButtons(title: "Dining", icon: Icons.local_dining),
const TopButtons(title: "Cafes", icon: Icons.local_cafe),
const TopButtons(
  title: "Stay",
  icon: Icons.home,
)
    ];

  List<Location> listOfLocations;
  List<Location> fliteredlistOfLocations;

@override
void initState() {
super.initState();
listOfLocations = this.widget.listOfLocations;
fliteredlistOfLocations = new List();
_controller = new TabController(length: 5, vsync: this,     initialIndex: 1);
_controller.addListener(updateList);
updateList();
  }

 void dispose() {
_controller.dispose();
super.dispose();
}

  @override
  Widget build(BuildContext context) {
return Scaffold(
    appBar: AppBar(
      title: Text("Location"),
      bottom:
          TabBar(controller: _controller, isScrollable: true, tabs:      <Tab>[
        Tab(text: typeList[0].title, icon: Icon(typeList[0].icon)),
        Tab(text: typeList[1].title, icon: Icon(typeList[1].icon)),
        Tab(text: typeList[2].title, icon: Icon(typeList[2].icon)),
        Tab(text: typeList[3].title, icon: Icon(typeList[3].icon)),
        Tab(text: typeList[4].title, icon: Icon(typeList[4].icon)),
      ]),
    ),
    body: SafeArea(
        child: ListView.builder(
            itemExtent: 100.0,
            padding: const EdgeInsets.all(10.0),
            itemCount: fliteredlistOfLocations.length,
            itemBuilder: (BuildContext ctxt, int index) =>
                buildBody(ctxt, index))));
  }
...