Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import 'package:flutter/material.dart';
import 'package:flutter_training/view/weather_view/weather_page.dart';
import 'package:flutter_training/routes.dart';

class App extends StatelessWidget {
const App({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
return MaterialApp.router(
routerConfig: router,
debugShowCheckedModeBanner: false,
title: 'Weather App',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const WeatherPage(),
);
}
}
16 changes: 16 additions & 0 deletions lib/routes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter_training/view/launch_view.dart';
import 'package:flutter_training/view/weather_view/weather_page.dart';
import 'package:go_router/go_router.dart';

final router = GoRouter(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

遷移先が増えていくにつれて見通しが悪くなるのでroutesの定義はroutesファイルに切り出しました。🙋‍♂️

routes: [
GoRoute(
path: LaunchView.path,
builder: (context, state) => const LaunchView(),
),
GoRoute(
path: WeatherPage.path,
builder: (context, state) => const WeatherPage(),
)
],
);
38 changes: 38 additions & 0 deletions lib/view/launch_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_training/view/weather_view/weather_page.dart';
import 'package:go_router/go_router.dart';

class LaunchView extends StatefulWidget {
const LaunchView({super.key});

static const path = '/';

@override
State<LaunchView> createState() => _LaunchViewState();
}

class _LaunchViewState extends State<LaunchView> {
Future<void> _toWeatherView() async {
await Future<void>.delayed(const Duration(milliseconds: 500));
if (!mounted) {
return;
}
await context.push(WeatherPage.path);
await _toWeatherView();
}

@override
void initState() {
super.initState();

WidgetsBinding.instance.endOfFrame.then((_) {
_toWeatherView();
});
}

@override
Widget build(BuildContext context) {
return Container(color: Colors.green);
}
}
6 changes: 5 additions & 1 deletion lib/view/weather_view/weather_page.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_training/model/weather.dart';
import 'package:flutter_training/view/weather_view/component/weather_forecast.dart';
import 'package:go_router/go_router.dart';
import 'package:yumemi_weather/yumemi_weather.dart';

final _weather = Weather(YumemiWeather());

class WeatherPage extends StatefulWidget {
const WeatherPage({super.key});

static const path = '/weather_page';

@override
State<WeatherPage> createState() => _WeatherPageState();
}
Expand Down Expand Up @@ -34,8 +38,8 @@ class _WeatherPageState extends State<WeatherPage> {
children: [
Expanded(
child: TextButton(
onPressed: context.pop,
child: const Text('Close'),
onPressed: () {},
),
),
Expanded(
Expand Down
21 changes: 21 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
go_router:
dependency: "direct main"
description:
name: go_router
sha256: "432409518740645ce7f28802171b78783197d01149fad44f9b8ae55f40277139"
url: "https://pub.dev"
source: hosted
version: "6.5.0"
js:
dependency: transitive
description:
Expand All @@ -115,6 +128,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
logging:
dependency: transitive
description:
name: logging
sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
matcher:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
flutter:
sdk: flutter
flutter_svg: ^2.0.4
go_router: ^6.5.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[感想]
今流行りのパッケージを使用していてチャレンジングでいいですね〜✨

yumemi_weather:
git:
url: https://github.com/yumemi-inc/flutter-training-template.git
Expand Down