Static Variables Static Methods
Complete Code For Static Variables Static Methods In Flutter
main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class Holder { static double number = 34567890 ; static void message(){ print('You are Calling Static Method'); } } 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 callStaticMember() { print(Holder.number); } void callStaticFunction() { Holder.message(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.blue[800], title: Text('Static Variables Static Methods'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( child: RaisedButton( onPressed: () => callStaticMember(), child: Text(' Call Static Variable '), textColor: Colors.white, color: Colors.green, ) ), Container( child: RaisedButton( onPressed: () => callStaticFunction(), child: Text(' Call Static Function '), textColor: Colors.white, color: Colors.blue[800], ) ), ]) ) ); } }