Ag cruthú Popover le Arrow i Flutter

Chun Flutter preabfhuinneog a chruthú le saighead a dhíríonn ar eilimint ar leith, is féidir leat an Popover ghiuirléid ón popover bpacáiste a úsáid. Seo mar is féidir leat é a dhéanamh:

Cuir an popover pacáiste le do pubspec.yaml chomhad:

dependencies:
  flutter:  
    sdk: flutter  
  popover: ^0.5.0  

Iompórtáil na pacáistí riachtanacha:

import 'package:flutter/material.dart';  
import 'package:popover/popover.dart';  

Úsáid an Popover ghiuirléid:

void main() {  
  runApp(MyApp());  
}  
  
class MyApp extends StatelessWidget {  
  @override  
  Widget build(BuildContext context) {  
    return MaterialApp(  
      home: MyHomePage(),  
   );  
  }  
}  
  
class MyHomePage extends StatelessWidget {  
  @override  
  Widget build(BuildContext context) {  
    return Scaffold(  
      appBar: AppBar(  
        title: Text('Popover Example'),  
     ),  
      body: Center(  
        child: Popover(  
          child: ElevatedButton(  
            onPressed:() {},  
            child: Text('Open Popup'),  
         ),  
          bodyBuilder:(BuildContext context) {  
            return Container(  
              padding: EdgeInsets.all(10),  
              child: Column(  
                mainAxisSize: MainAxisSize.min,  
                children: [  
                  Text('This is a popover with an arrow.'),  
                  SizedBox(height: 10),  
                  Icon(Icons.arrow_drop_up, color: Colors.grey),  
                ],  
             ),  
           );  
          },  
       ),  
     ),  
   );  
  }  
}  

Sa sampla seo, Popover úsáidtear an ghiuirléid chun aníos a chruthú le saighead ag díriú ón gcnaipe chuig an ábhar. Is é an child t-airí an eilimint a spreagann an popover, agus bodyBuilder is aisghlao é an t-airí a thugann ábhar an phríosúin ar ais.

Cuimhnigh ábhar, cuma agus iompar an popover a shaincheapadh de réir do riachtanais. Léiríonn an sampla seo úsáid an popover phacáiste chun popovers a chruthú le saigheada i Flutter.