Facebook
From Bonyadi, 5 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 127
  1. // Copyright (c) 2019, the Dart project authors.  Please see the AUTHORS file
  2. // for details. All rights reserved. Use of this source code is governed by a
  3. // BSD-style license that can be found in the LICENSE file.
  4.  
  5. import 'package:flutter/material.dart';
  6.  
  7. void main() {
  8.   runApp(MyApp());
  9. }
  10.  
  11. class MyApp extends StatelessWidget {
  12.   @override
  13.   Widget build(BuildContext context) {
  14.     return MaterialApp(
  15.       title: 'my app',
  16.       debugShowCheckedModeBanner: false,
  17.       theme: ThemeData(
  18.         colorScheme: ColorScheme.fromSeed(seedColor: Colors.red),
  19.         useMaterial3: true,
  20.       ),
  21.       home: MainPage(),
  22.     );
  23.   }
  24. }
  25.  
  26.  
  27. class MainPage extends StatefulWidget {
  28.   State<MainPage> createState() => _MainPage();
  29. }
  30.  
  31. class _MainPage extends State<MainPage> {
  32.   String value = "";
  33.   Widget build(BuildContext context) {
  34.     return Scaffold(
  35.       body: ElevatedButton(
  36.         onPressed: () {
  37.           print("Hello");
  38.         },
  39.         child: Text("Click me"),
  40.       ),
  41.     );
  42.   }
  43. }
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. class MyHomePage extends StatefulWidget {
  62.   final String title;
  63.  
  64.   const MyHomePage({
  65.     Key? key,
  66.     required this.title,
  67.   }) : super(key: key);
  68.  
  69.   @override
  70.   State<MyHomePage> createState() => _MyHomePageState();
  71. }
  72.  
  73. class _MyHomePageState extends State<MyHomePage> {
  74.   int _counter = 0;
  75.  
  76.   void _incrementCounter() {
  77.     setState(() {
  78.       _counter++;
  79.     });
  80.   }
  81.  
  82.   @override
  83.   Widget build(BuildContext context) {
  84.     return Scaffold(
  85.       appBar: AppBar(
  86.         backgroundColor: Theme.of(context).colorScheme.inversePrimary,
  87.         title: Text(widget.title),
  88.       ),
  89.       body: Center(
  90.         child: Column(
  91.           mainAxisAlignment: MainAxisAlignment.center,
  92.           children: [
  93.             const Text(
  94.               'You have pushed the button this many times:',
  95.             ),
  96.             Text(
  97.               '$_counter',
  98.               style: Theme.of(context).textTheme.headlineMedium,
  99.             ),
  100.           ],
  101.         ),
  102.       ),
  103.       floatingActionButton: FloatingActionButton(
  104.         onPressed: _incrementCounter,
  105.         tooltip: 'Increment',
  106.         child: const Icon(Icons.add),
  107.       ),
  108.     );
  109.   }
  110. }