mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Added missing login page (#339)
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:provider_shopper/models/cart.dart';
|
||||
import 'package:provider_shopper/models/catalog.dart';
|
||||
import 'package:provider_shopper/screens/cart.dart';
|
||||
import 'package:provider_shopper/screens/catalog.dart';
|
||||
import 'package:provider_shopper/screens/login.dart';
|
||||
|
||||
void main() {
|
||||
runApp(MyApp());
|
||||
@@ -39,7 +40,8 @@ class MyApp extends StatelessWidget {
|
||||
theme: appTheme,
|
||||
initialRoute: '/',
|
||||
routes: {
|
||||
'/': (context) => MyCatalog(),
|
||||
'/': (context) => MyLogin(),
|
||||
'/catalog': (context) => MyCatalog(),
|
||||
'/cart': (context) => MyCart(),
|
||||
},
|
||||
),
|
||||
|
||||
48
provider_shopper/lib/screens/login.dart
Normal file
48
provider_shopper/lib/screens/login.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright 2020 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/material.dart';
|
||||
|
||||
class MyLogin extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(80.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Welcome',
|
||||
style: Theme.of(context).textTheme.display4,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Username',
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Password',
|
||||
),
|
||||
obscureText: true,
|
||||
),
|
||||
SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
RaisedButton(
|
||||
color: Colors.yellow,
|
||||
child: Text('ENTER'),
|
||||
onPressed: () {
|
||||
Navigator.pushReplacementNamed(context, '/catalog');
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,10 @@ void main() {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(MyApp());
|
||||
|
||||
// Navigating through login page.
|
||||
await tester.tap(find.text('ENTER'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Check that shopping cart is empty at start.
|
||||
await tester.tap(find.byIcon(Icons.shopping_cart));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Reference in New Issue
Block a user