본문 바로가기
TIL

20230904 TIL : 믿음의 월요일 라스고

by 김빵그 2023. 9. 4.

Today 요약

[] 프로그래머스 코딩테스트 1문제

[] flutter 강의 2개

[] 개발 책 3P


배운 점

1) flutter Gorouter parameters

  • GoRouter와 Navigator 1.0을 조합해서 만들수도 있음

1-1 Goroute

 

GoRouter class - go_router library - Dart API

The route configuration for the app. The routes list specifies the top-level routes for the app. It must not be empty and must contain an GoRouter to match /. See the Get started example, which shows an app with a simple route configuration. The redirect c

pub.dev

final router = Gorouter(
	routes:[
    	GoRoute(
        	path:"/users/:username", //변수처리
            builder : (context,state) {
            	final  username = state.params['username'];
                return ProfileScreen(username:username!)
            }
        )
    ]
);
  • 변수선언 : 네임
  • username! 느낌표를 붙여서 값이 항상 있을거라고 표시해준다

1-2 ProfileScreen

class ProfileScreen extends StatefulWidget {
	final String username; 
    const ProfileScreen({super.key, required this.username});
}
....생략
Text(widget.username), 
Text("@${widget.username}")

2) 클릭한 값에 따른 탭 변경 > 쿼리 매개변수

void _tap() => context.go('/search?query=kitties');
GoRoute(
  path: '/search',
  builder: (context, state) {
    // use state.queryParams to get search query from query parameter
    final query = state.queryParams['query']; // may be null
    return SearchPage(query: query);
  },
),

2-1 router

final router = Gorouter(
	routes:[
    	GoRoute(
        	path:"/users/:username", //변수처리
            builder : (context,state) {
            	final  username = state.params['username'];
                final tab = state.queryParams["show"]; // 추가
                return ProfileScreen(username:username!, tab : tab!);
            }
        )
    ]
);

2-2 screen

class ProfileScreen extends StatefulWidget {
	final String username; 
    final String tab; //추가
    const ProfileScreen({super.key, required this.username, required this.tab,});
}
....생략
DefaultTabController (
	initialIndex : widget.tab == "photo" ? 0 : 1,
    length: 2,
    child : 
	...생략
    Text(widget.username), 
    Text("@${widget.username}")
)

 

3) extra parameter

  • 다른 화면에 추가 정보를 보내는데 그 정보를 url에 담지 않으면서 보내는 방법
void _tap() => context.go('/family', extra: _family);

GoRoute(
  path: '/family',
  builder: (context, state) => FamilyScreen(family: state.extra! as Family),
),

3-1 FirstScreen

void _onNext() {
	if(_username.isEmpty) return; 
    context.push(
    	SecondScreen.routeName, 
        extra : SecondScreenArgs(username:_username),
    );
}

3-2 SecondScreen

class SecondScreenArgs {
	final String username; 
    SecondScreenArgs({required this.username}); 
}
class SecondScreen extends StatefulWidget {
	static String routeName = "/second";
    final String username; 
}

4) 자바스크립트란?

 

자바스크립트란?

 

ko.javascript.info

정의

  • 웹페이지에 생동감을 붙여넣기 위해 만들어진 프로그래밍 언어
  • 자바스크립트로 작성한 프로그램을 스크립트 라고 부른다
  • 스크립트는 웹페이지의 HTML 안에 작성할 수 있는데 웹페이지를 불러올 때 자동으로 스크립트가 실행된다
  • 자바(Java)와는 매우 다른 언어
  • HTML ? 프로그래밍 언어가 아닌 하이터 펙스트 마크업 언어. 인터넷에서 사용가와 서버과 정보를 주고받기 위한 일종의 규칙

주절주절

월요일마다 정신이 번쩍 드는 게 있다 운동도 하고 공부도 하고 월요일 한정 갓생모드 on