Notice
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 |
Tags
- 클로저
- git pair
- lightsail nodejs apache
- TypeScript
- OOP
- ESLint
- NPM
- #cloudfront #s3 #html 확장자 없애기
- 객체참조 #객체
- jest
- this
- 기후변화
- url #querystring
Archives
- Today
- Total
Hello World...
Flutter current path 본문
current path 를 확인하려면 ModalRoute 를 사용하면 된다.
import 'package:flutter/material.dart';
class ShopDrawer extends StatelessWidget {
const ShopDrawer({super.key});
@override
Widget build(BuildContext context) {
// current path 를 알기 위해 활용
var route = ModalRoute.of(context);
if (route != null) {
print('current path: ${route.settings.name}');
}
// -------------------------------
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
child: Column(
children: [
Text(
'Best Shop',
style: TextStyle(
color: Theme.of(context).colorScheme.inversePrimary,
fontSize: 24,
),
),
],
),
),
ListTile(
leading: const Icon(Icons.shopping_bag),
title: const Text('Shop'),
onTap: () {
Navigator.pop(context);
if (route?.settings.name != '/shop_screen') {
Navigator.pop(context);
Navigator.pushNamed(context, '/shop_screen');
}
},
),
ListTile(
leading: const Icon(Icons.shopping_cart),
title: const Text('Cart'),
onTap: () {
Navigator.pop(context);
if (route?.settings.name != '/cart_screen') {
Navigator.pop(context);
Navigator.pushNamed(context, '/cart_screen');
}
},
)
],
),
);
}
}
'flutter' 카테고리의 다른 글
| 플러터 카카오로그인 윈도우 invalid android_key_hash or ios_bundle_id or web_site_url (0) | 2024.01.06 |
|---|---|
| 플러터 - 아이폰 기기에서 개발자 모드로 앱 실행해보기 (1) | 2023.12.07 |
| 플러터 Dio url localhost 에러 관련 (0) | 2023.12.06 |
| 플러터 iOS WebView 구글 로그인 403 Error (0) | 2023.10.16 |
Comments