Anyone please give some information why this is happening?
When I try to add a class AppBarDesign which implements appBar flutter is giving the below error.
error: The argument type 'AppBarDesign' can't be assigned to the parameter type 'PreferredSizeWidget'. (argument_type_not_assignable at [flutterbyrajath] libmain.dart:27)
import 'package:flutter/material.dart';
main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Rajath's design ',
debugShowCheckedModeBanner: false,
theme: new ThemeData(primarySwatch: Colors.amber),
home: new MyHomePage(key, 'App is Fun'),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage(Key key, this.title) : super(key: key);
final title;
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBarDesign(key, title),
);
}
}
class AppBarDesign extends StatelessWidget {
AppBarDesign(Key key, this.title) : super(key: key);
final title;
@override
Widget build(BuildContext context) {
return new AppBar(
title: new Text(title),
);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…