Fat Arrow One Line Function
Complete Code For Fat Arrow One Line Function In Flutter
main.dart
import 'package:flutter/material.dart';
void main(){
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
void shortFunction() => print('Fat Arrow One Line Function Called');
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
backgroundColor: Colors.blue[700],
title: Text('Fat Arrow One Line Function'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
child: RaisedButton(
onPressed: () => shortFunction(),
child: Text('Call One Line Short Function'),
textColor: Colors.white,
color: Colors.blue[700],
)
),
])
)
);
}
}