Facebook
From dfdf, 2 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 159
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() {
  4.   runApp(MyApp());
  5. }
  6.  
  7. class MyApp extends StatefulWidget {
  8.   MyApp({super.key});
  9.  
  10.   @override
  11.   State<MyApp> createState() => _MyAppState();
  12. }
  13.  
  14. class _MyAppState extends State<MyApp> {
  15.   List quotes = [
  16.     "Raczej siebie oskarżajmy, a nie innych",
  17.     "W życiu nigdy nie jest za późno na trzy rzeczy: miłość, naukę i spełnianie marzeń",
  18.     "Kiedy mamy marzenia, ale nie próbujemy ich spełniać, życie staje się koszmarem",
  19.     "Rób to, co możesz, tym, co posiadasz, i tam, gdzie jesteś"
  20.   ];
  21.  
  22.   int position = 0;
  23.  
  24.   @override
  25.   Widget build(BuildContext context) {
  26.     return MaterialApp(
  27.       home: Scaffold(
  28.         appBar: AppBar(
  29.           title: Text("Cytaty"),
  30.           backgroundColor: Colors.limeAccent,
  31.         ),
  32.         body: Column(
  33.           children: [
  34.             Container(
  35.               alignment: Alignment.center,
  36.               height: 200,
  37.               padding: EdgeInsets.symmetric(horizontal: 40),
  38.               child: Text(quotes[position]),
  39.             ),
  40.             Divider(thickness: 4),
  41.             SizedBox(height: 50),
  42.             GestureDetector(
  43.               onTap: () {
  44.                 setState(() {
  45.                   if(position < quotes.length - 1) {
  46.                     position++;
  47.                   } else {
  48.                      positi
  49.                   }
  50.                 });
  51.               },
  52.               child: Container(
  53.                 width: 150,
  54.                 padding: EdgeInsets.all(14),
  55.                 decoration: BoxDecoration(
  56.                   color: Colors.amber,
  57.                   borderRadius: BorderRadius.circular(5)
  58.                 ),
  59.                 child: Row(
  60.                   mainAxisAlignment: MainAxisAlignment.center,
  61.                   children: [
  62.                     Container(
  63.                       decoration: BoxDecoration(
  64.                         borderRadius: BorderRadius.circular(4),
  65.                         border: Border.all(
  66.                           width: 3,
  67.                           color: Colors.blue
  68.                         )
  69.                       ),
  70.                       child: Icon(Icons.question_mark, color: Colors.blue),
  71.                     ),
  72.                     SizedBox(width: 5),
  73.                     Text("New Quote", style: TextStyle(
  74.                         color: Colors.blue,
  75.                         fontWeight: FontWeight.bold
  76.                     ))
  77.                   ],
  78.                 )
  79.               ),
  80.             )
  81.           ],
  82.         )
  83.       )
  84.     );
  85.   }
  86. }
  87.