switch
flutter 찍먹 본문
스프링공부를 시작하면서 프론트단을 플러터로 작성해보기로했다
책으로 간략히 dart문법을익히고..
main.dart에 그냥 작성하면됨..
1.state 사용
//state사용
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int stateTab = 0;
...
onTap: (i){
setState(() {
stateTab = i;
});
},
...
}
중간에 코드가 많이 생략됐지만 대충 이런식으로 사용한다
2. http연결
get 요청의 경우
getData() async {
dynamic result = await http.get(Uri.parse('http://localhost:3000'));
print(result.body);
print(jsonDecode(result.body));
}
@override
void initState() {
super.initState();
getData();
}
세팅끝나면 이런식으로 연결하면됨..
'front-end > flutter' 카테고리의 다른 글
[flutter]폰에 저장된 이미지 사용하기(image_picker) (0) | 2022.04.29 |
---|
Comments