name27 / flutter

0 stars 0 forks source link

Controller #42

Open name27 opened 1 year ago

name27 commented 1 year ago
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    var idController = TextEditingController(text: ''); //myController에 TextEditingController를 만들어서 집어넣음
    var pwController = TextEditingController(text: '');
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Column(
            children: [
              TextField(
                controller: idController,
              ),
              TextField(
                controller: pwController,
                obscureText: true,
              ),
              TextButton(
                onPressed: (){
                  print(idController.text);
                  print(pwController.text);
                },
                child: Text('로그인'),
              ),
              // TextButton(
              //   onPressed: (){
              //     print(idController.text);
              //   },
              //   child: Text('hit me'),
              // ),
              // TextButton(
              //   onPressed: (){
              //     idController.text = '';
              //   },
              //   child: Text('Erase'),
              // ),
            ],
          ),
        ),
      ),
    );
  }
}
name27 commented 1 year ago
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    var pageController = PageController();
    return MaterialApp(
      home: Scaffold(
        body: DefaultTextStyle(
          style: TextStyle(fontSize: 36, color: Colors.black),
          child: SafeArea(
            child: PageView(
              physics: NeverScrollableScrollPhysics(),
              controller: pageController,
              onPageChanged: ((v) {
                print(v);
              }),
              children: [
                Text('A페이지'),
                Text('B페이지'),
                Text('C페이지')
              ],
            ),
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: (){
            pageController.previousPage(duration: Duration(seconds: 2), curve: Curves.easeIn);
          },
          child: Icon(Icons.navigate_next),
        ),
      ),
    );
  }
}
name27 commented 1 year ago

textfield