Copy and Paste  -   An Application to Copy/Paste Text  

 
S.No 5973 Name C34 Date/Time 02-Jul-2024 03:07:34 PM

Copy text from below
/*
Question C34:
You have a layout as given in the following.
 
You need to write a “single method” for all the three buttons. The prototype of method is:
function button_Click().
In this method, you need to get the text of the button clicked. If the text is matching with the string “ISLAMABAD”, the <Text> should be assigned value ISLAMABAD, otherwise it remains blank.
*/

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(title: 'Flutter Demo', home: MyApp()));
}

class MyApp extends StatelessWidget {
  String cityInfo = "";

  MyApp({super.key});

  void button_click(String city) {
    debugPrint("CITY $city");

    setState(() {
      cityInfo = city == "ISLAMABAD" ? "ISLAMABAD" : "";
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text("The capital of Pakistan is ${cityInfo}"),
        Row(children: [
          ElevatedButton(
              onPressed: () => button_click("KARACHI"), child: Text("KARACHI")),
          ElevatedButton(
              onPressed: () => button_click("LAHORE"), child: Text("LAHORE")),
          ElevatedButton(
              onPressed: () => button_click("ISLAMABAD"),
              child: Text("ISLAMABAD")),
        ])
      ],
    ));
  }
}




comments powered by Disqus
NEW ENTRIES
S.No Name Entry Time/Date
5827 q4 10-Oct-2023 05:40:56 PM
5826 jflex q3 10-Oct-2023 05:37:43 PM
5825 q3 10-Oct-2023 05:33:13 PM
5824 q2 10-Oct-2023 05:32:15 PM
5823 jflex 10-Oct-2023 05:30:32 PM
5822 dddd 10-Oct-2023 04:41:21 PM
5821 nn 09-Oct-2023 11:55:27 AM
5820 Jarvo 09-Oct-2023 11:44:19 AM
5819 NEW CHILD 07-Oct-2023 11:16:57 AM
5818 05-Oct-2023 06:32:33 PM
5817 LandscapeLay 05-Oct-2023 11:42:00 AM
5813 responsive 02-Oct-2023 11:44:41 AM
5806 lab task 26-Sep-2023 05:28:21 PM
5805 q 4 26-Sep-2023 05:19:19 PM
5804 111 26-Sep-2023 04:45:42 PM
5803 comp 26-Sep-2023 04:14:07 PM
5802 COlor 25-Sep-2023 03:03:06 PM
5801 islamabad 25-Sep-2023 02:56:47 PM
5800 Ikack 25-Sep-2023 02:27:21 PM
5799 Blue Green n 25-Sep-2023 02:01:07 PM
5798 Jask 25-Sep-2023 01:59:04 PM
5797 Blue Green 25-Sep-2023 01:59:02 PM
5796 fire-wood-wa 25-Sep-2023 12:49:39 PM
5795 6001 25-Sep-2023 11:54:34 AM
5794 23-Sep-2023 08:28:04 PM
5793 Child Hot 22-Sep-2023 11:53:03 AM
5792 dfd 22-Sep-2023 10:42:45 AM
5791 Codeeee 22-Sep-2023 09:44:28 AM
5790 HEC 22-Sep-2023 09:41:20 AM
5789 llllllllll 22-Sep-2023 09:20:11 AM

[First] [Prev] 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 [Next] [Last]
 
web counter
web counter


To report any error messages or bugs, or other issues, please send email at: info@pakproject.com