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 (c) 2019, the Dart project authors. Please see the AUTHORS file | |
// for details. 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'; | |
Future<void> asyncFunction() async { | |
print('a'); | |
await Future.value(); | |
print('b'); |
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
import 'package:flutter/material.dart'; | |
import 'package:provider/provider.dart'; | |
import 'package:providerlogin/model/user_repository.dart'; | |
class LoginPage extends StatefulWidget { | |
@override | |
_LoginPageState createState() => _LoginPageState(); | |
} | |
class _LoginPageState extends State<LoginPage> { |
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
import 'package:firebase_auth/firebase_auth.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:provider/provider.dart'; | |
import 'package:providerlogin/login_page.dart'; | |
import 'package:providerlogin/model/user_repository.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override |
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
import 'package:flutter/widgets.dart'; | |
import 'package:firebase_auth/firebase_auth.dart'; | |
enum Status { Uninitialized, Authenticated, Authenticating, Unauthenticated } | |
class UserRepository with ChangeNotifier { | |
FirebaseAuth _auth; | |
FirebaseUser _user; | |
Status _status = Status.Uninitialized; |
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
class HomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
// Builder takes three parameters 1. [BuildContext] which is our context | |
// 2. [Object] it is the object and 3. it is optional [Widget] child | |
return Consumer( | |
builder: (context, Counter counter, _) => Scaffold( | |
appBar: AppBar( | |
title: Text("Provider Demo"), |
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
class HomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
final counter = Provider.of<Counter>(context); | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Provider Demo"), | |
), | |
body: Center( |
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
import 'package:flutter/material.dart'; | |
class Counter with ChangeNotifier { | |
int _counter; | |
Counter(this._counter); | |
getCounter() => _counter; | |
setCounter(int counter) => _counter = counter; |
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
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( |