Skip to content
Snippets Groups Projects
Commit ee6b8a7a authored by 김다은's avatar 김다은
Browse files

navigator

parent 34cd82c5
Branches
No related tags found
No related merge requests found
// checklist_view.dart
import 'package:flutter/material.dart';
class ChecklistView extends StatefulWidget {
const ChecklistView({super.key});
@override
State<ChecklistView> createState() => _ChecklistViewState();
}
class _ChecklistViewState extends State<ChecklistView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('checklist')),
body: Container(),
);
}
}
// main.dart // main.dart
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_application_0430/checklist_view.dart';
void main() { void main() => runApp(const MyApp());
runApp(const MyApp());
}
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({super.key}); const MyApp({super.key});
...@@ -18,46 +17,34 @@ class MyApp extends StatelessWidget { ...@@ -18,46 +17,34 @@ class MyApp extends StatelessWidget {
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title}); const MyHomePage({super.key, required this.title});
final String title; final String title;
@override @override
State<MyHomePage> createState() => _MyHomePage(); State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void _moveView() {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const ChecklistView()),
);
} }
class _MyHomePage extends State<MyHomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(widget.title)), appBar: AppBar(title: Text(widget.title)),
body: Container( body: Center( // 가운데 배치
margin: const EdgeInsets.all(20), child: GestureDetector(
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20), onTap: _moveView, // 탭 시 화면 전환
child: Center( child: Container(
child: Column( width: 40,
mainAxisAlignment: MainAxisAlignment.start, height: 40,
children: [
Container(
width: 400,
height: 200,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.black, width: 2), border: Border.all(color: Colors.black),
),
child: const Text('text in box'),
),
const Text('text outside of box'),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Text('text in Row'),
Container(
width: 100,
height: 100,
child: const Icon(Icons.flag),
),
],
), ),
], child: const Text('move'),
), ),
), ),
), ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment