su
Constructor de la clase Align:
Syntax: Align({Key key, AlignmentGeometry alignment: Alignment.center, double widthFactor, double heightFactor, Widget child})
Propiedades del widget Alinear:
- alineación: Establece la alineación.
- child: El widget hijo en el árbol.
- hashCode: el código hash del objeto.
- factor de altura :
- la
Dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'TextSpan', theme: ThemeData( primarySwatch: Colors.green, ), home: MyHomePage(), debugShowCheckedModeBanner: false, ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('GeeksforGeeks Align Widget'), backgroundColor: Colors.green), body: Center( child: Container( height: 120.0, width: 120.0, color: Colors.blue[50], child: Align( alignment: Alignment.center, child: Text( "Geeky Text", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), ), ))); } }
Producción:
Dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'TextSpan', theme: ThemeData( primarySwatch: Colors.green, ), home: MyHomePage(), debugShowCheckedModeBanner: false, ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('GeeksforGeeks Align Widget'), backgroundColor: Colors.green), body: Center( child: Container( height: 240.0, width: 240.0, color: Colors.green, child: Align( alignment: Alignment.topRight, child: Image.network( "https://www.geeksforgeeks.org/wp-content/uploads/gfg_200X200-1.png", width: 100, )), ))); } }
Producción: