본문 바로가기
TIL

20230606 TIL

by 김빵그 2023. 6. 6.

Today 요약

[]

 

배운 점

1. GestureDetector

  • gestureDetector onTap을 사용하여 다른 스크린으로 이동시 만약 다른 스크린이 satefulWidget이라면 context를 넘겨줘야 한다
void _onNextScreen(BuilderContext context){
	Navigator.of(context).push(
    	MaterialPageRoute(builder:(context) => const
        NextScreen()),
    );
}

GestureDetecor(
	onTap:()=>_onNextScreen(context),
    child:,,,,

)

2. Form 유효성 검사

2-1 GlobalKey 만들기

class MyCustomFormState extends State<MyCustomForm> {
  final _formKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    return Form(
      key: _formKey,
      child: const Column(
        children: <Widget>[
        ],
      ),
    );
  }
}

2-2 유효성 검사 추가

TextFormField(
  validator: (value) {
    if (value == null || value.isEmpty) {
      return 'Please enter some text';
    }
    return null;
  },
),

2-3 버튼 추가

ElevatedButton(
  onPressed: () {
    if (_formKey.currentState!.validate()) {
      ScaffoldMessenger.of(context).showSnackBar(
        const SnackBar(content: Text('Processing Data')),
      );
    }
  },
  child: const Text('Submit'),
),

3. Wrap

Wrap(
	runSpacing:10, // 위아래 여백
    spacing :10 , // 좌우 여백
	children:,..
)

4. CupertinoButton

CupertinoButton (
	onPressed:(){},
    color:Colors.pink, 
    child:Text("다음"),
)
  • textbutton보다 좀더 나은듯한 기분? 

'TIL' 카테고리의 다른 글

20230612 TIL  (0) 2023.06.12
20230607 TIL  (0) 2023.06.07
20230604 TIL  (1) 2023.06.04
20230603 TIL  (1) 2023.06.03
20230522 TIL  (0) 2023.05.22