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 Login extends StatefulWidget { | |
| @override | |
| _LoginState createState() => _LoginState(); | |
| } | |
| class _LoginState extends State<Login> { | |
| String _email; | |
| String _password; |
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:flutter_app/login.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| // This widget is the root of your application. | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( |
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 React, { Component, createRef } from 'react'; | |
| export default class CMP extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.refA = createRef(); | |
| this.refB = createRef(); | |
| } | |
| render() { |
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
| final _loginFormKey = GlobalKey<FormState>(); | |
| // This method call the functions in our component's | |
| // validator property. | |
| _loginFormKey.currentState.validate(); | |
| // This method call the functions in our component's | |
| // onSaved method. |
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
| final _loginFormKey = GlobalKey<FormState>(); | |
| // This method call the functions in our component's | |
| // validator property. | |
| _loginFormKey.currentState.validate(); | |
| // This method call the functions in our component's | |
| // onSaved method. |
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
| TextFormField( | |
| validator: (val) { | |
| if (val.isEmpty) { | |
| return 'You must enter a valid email!'; | |
| } | |
| return null; | |
| }, | |
| onSaved: (val) => _email = val, | |
| ), |
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
| RaisedButton( | |
| child: Text('Login'), | |
| onPressed: () { | |
| if (_loginFormKey.currentState.validate()) { | |
| _loginFormKey.currentState.save(); | |
| print('Email: $_email, password: $_password'); | |
| } | |
| }, | |
| ), |
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: 'My Weather App', | |
| home: MyHomePage(), |
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:geolocator/geolocator.dart'; | |
| class _MyHomePageState extends State<MyHomePage> { | |
| [...] | |
| Future<Position> getPosition() async { | |
| Position position = await Geolocator() | |
| .getCurrentPosition(desiredAccuracy: LocationAccuracy.high); | |
| return position; |
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:geolocator/geolocator.dart'; | |
| class _MyHomePageState extends State<MyHomePage> { | |
| [...] | |
| String _locality = ''; | |
| Future<Placemark> getPlacemark(double latitude, double longitude) async { | |
| List<Placemark> placemark = await Geolocator() |