mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Creates the start of the Rolodex app. Sets up the app with the initial routes setup. Since the native Contacts app does not open on its home screen, and instead opens on the default list of contacts, it felt important to set that up first. Some basic app state management is also setup for managing contact lists across the app. Boilerplate visuals are setup for two of the screens. Improved fidelity will come later. <img width="855" alt="Screenshot 2025-01-27 at 12 09 57 PM" src="https://github.com/user-attachments/assets/de091c7c-11ac-4350-9362-61b9c26b2aca" /> <img width="841" alt="Screenshot 2025-01-27 at 12 04 07 PM" src="https://github.com/user-attachments/assets/fe822b06-a432-44cf-ab24-f3e7a88955e5" />
54 lines
1.4 KiB
Dart
54 lines
1.4 KiB
Dart
// Copyright 2018 The Flutter team. 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:flutter/cupertino.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'data/contact_list.dart';
|
|
import 'screens/contacts.dart';
|
|
import 'screens/lists.dart';
|
|
|
|
void main() {
|
|
runApp(const RolodexApp());
|
|
}
|
|
|
|
class RolodexApp extends StatelessWidget {
|
|
const RolodexApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ChangeNotifierProvider(
|
|
create: (context) => ContactListsModel(),
|
|
child: CupertinoApp(
|
|
title: 'Rolodex',
|
|
initialRoute: '/contacts',
|
|
onGenerateInitialRoutes: (initialRoute) {
|
|
return [
|
|
CupertinoPageRoute(
|
|
title: 'Lists',
|
|
builder: (BuildContext context) {
|
|
return ListsPage();
|
|
},
|
|
),
|
|
CupertinoPageRoute(
|
|
builder: (BuildContext context) {
|
|
return ContactListsPage(listId: 0);
|
|
},
|
|
),
|
|
];
|
|
},
|
|
onUnknownRoute: (RouteSettings settings) {
|
|
return CupertinoPageRoute(
|
|
builder: (BuildContext context) {
|
|
return const CupertinoPageScaffold(
|
|
child: Center(child: Text('Unknown Route')),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|