Open name27 opened 1 year ago
import 'package:flutter/material.dart';
class MainPage extends StatelessWidget {
const MainPage({super.key});
@override
Widget build(BuildContext context) {
var _pageController = PageController();
List<Map<String, String>> words = [
{
"word": "apple",
"meaning": "사과",
"example": "I want to eat an apple"
},
{
"word": "paper",
"meaning": "종이",
"example": "Could you give me a paper"
},
{
"word": "resilient",
"meaning": "탄력있는, 회복력있는",
"example": "She's a resilient girl"
},
{
"word": "revoke",
"meaning": "취소하다",
"example": "The authorities have revoked their original decision to allow development of this rural area."
},
{
"word": "withdraw",
"meaning": "철회하다",
"example": "After lunch, we withdrew into her office to finish our discussion in private."
},
];
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
),
body: PageView.builder(
controller: _pageController,
itemCount: words.length,
itemBuilder: (context, index) => Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
words[index]["word"].toString(),
style: TextStyle(
fontSize: 30,
letterSpacing: -1,
fontWeight: FontWeight.bold
),
),
SizedBox(height: 8,),
Text(
words[index]["meaning"]!,
style: TextStyle(
letterSpacing: -1,
color: Colors.grey,
fontWeight: FontWeight.bold
),
),
SizedBox(height: 16,),
Text(
'"${words[index]["example"]!}"',
style: TextStyle(
letterSpacing: 1,
),
textAlign: TextAlign.center,
),
],
)
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
FloatingActionButton(
child: Icon(Icons.navigate_before),
onPressed: (){
_pageController.previousPage(duration: Duration(seconds: 1), curve: Curves.easeIn);
}
),
FloatingActionButton(
child: Icon(Icons.navigate_next),
onPressed: (){
_pageController.nextPage(duration: Duration(seconds: 1), curve: Curves.easeIn);
}
),
],
),
),
);
}
}
main.dart
main_Page.dart
WordTile.dart