Tugas 13 Pemrograman Perangkat Bergerak
Nama: Amanda Salwa Salsabila
NRP: 5025201172
Tugas 13 PPB
Latihan Membuat Aplikasi Music Menggunakan Flutter
Berikut merupakan source code dari halaman antarmuka pengguna
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 The Flutter Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style license that can be | |
// found in the LICENSE file. | |
import 'package:dynamic_color/dynamic_color.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import 'playback/bloc/bloc.dart'; | |
import 'providers/theme.dart'; | |
import 'router.dart'; | |
import 'views/views.dart'; | |
class MyApp extends StatefulWidget { | |
const MyApp({super.key}); | |
@override | |
State<MyApp> createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
final settings = ValueNotifier(ThemeSettings( | |
sourceColor: Colors.pink, | |
themeMode: ThemeMode.system, | |
)); | |
@override | |
Widget build(BuildContext context) { | |
return BlocProvider<PlaybackBloc>( | |
create: (context) => PlaybackBloc(), | |
child: DynamicColorBuilder( | |
builder: (lightDynamic, darkDynamic) => ThemeProvider( | |
lightDynamic: lightDynamic, | |
darkDynamic: darkDynamic, | |
settings: settings, | |
child: NotificationListener<ThemeSettingChange>( | |
onNotification: (notification) { | |
settings.value = notification.settings; | |
return true; | |
}, | |
child: ValueListenableBuilder<ThemeSettings>( | |
valueListenable: settings, | |
builder: (context, value, _) { | |
final theme = ThemeProvider.of(context); | |
return MaterialApp.router( | |
debugShowCheckedModeBanner: false, | |
title: 'Flutter Demo', | |
theme: theme.light(settings.value.sourceColor), | |
darkTheme: theme.dark(settings.value.sourceColor), | |
themeMode: theme.themeMode(), | |
routeInformationParser: appRouter.routeInformationParser, | |
routeInformationProvider: | |
appRouter.routeInformationProvider, | |
routerDelegate: appRouter.routerDelegate, | |
builder: (context, child) { | |
return PlayPauseListener(child: child!); | |
}, | |
); | |
}, | |
), | |
)), | |
), | |
); | |
} | |
} |
Comments
Post a Comment