The code was working well till when I tried Extract CupertinoNavigationBar to a widget.
May Anyone please give some information why this issue happening?
It gives me this error:
Error: The argument type 'HomePageAppBar' can't be assigned to the parameter type 'ObstructingPreferredSizeWidget?'. package:flutter_todo_app/main.dart:27
- 'HomePageAppBar' is from 'package:flutter_todo_app/main.dart' ('lib/main.dart'). package:flutter_todo_app/main.dart:1
- 'ObstructingPreferredSizeWidget' is from 'package:flutter/src/cupertino/page_scaffold.dart' ('../../development/flutter/packages/flutter/lib/src/cupertino/page_scaffold.dart'). package:flutter/…/cupertino/page_scaffold.dart:1 navigationBar: HomePageAppBar(), ^
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'widgets/body.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return CupertinoApp(
debugShowCheckedModeBanner: false,
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: HomePageAppBar(),
child: HomePageBody(),
);
}
}
class HomePageAppBar extends StatelessWidget {
const HomePageAppBar({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoNavigationBar(
middle: const Text('app bar'),
);
}
}